Amazon.com Inc’s efforts to get packages from warehouse to doorstep in a single day helped push the retail giant to its first year-on-year quarterly profit decline since early 2017 and the spending binge is not over.

Amazon chief financial officer Brian Olsavsky on Thursday said that the costs of the company’s one-day delivery push would be about US$1.5 billion during the fourth quarter.

Amazon’s forecasts for operating income and sales in the period fell short of analysts’ estimates and its shares slumped as much as 9.1 percent in extended trading.

Amazon chief executive Jeff Bezos has promised since the company’s initial public offering to invest for the long haul and he is proving again his willingness to endure a little short-term pain in a bid to expand.

Facing slowing growth in its core e-commerce business, Amazon in April announced an initiative to cut the delivery window on millions of items for paying members of its Prime subscription program.

That has helped reinvigorate sales, if at a high price.

“Customers love the transition of Prime from two days to one day — they’ve already ordered billions of items with free one-day delivery this year,” Bezos said in a statement. “It’s a big investment and it’s the right long-term decision for customers.”

The investments taking place across Amazon’s warehouses are “strategically necessary,” but they “continued to weigh heavily” on the profitability of the retail business, Moody’s Investors Service analyst Charlie O’Shea said.

Third-quarter net income narrowed to US$2.13 billion, or earnings per share of US$4.23, from US$2.88 billion, or US$5.75, a year earlier, the Seattle-based company said in the statement.

It was the first year-on-year decline since the second quarter of 2017.

Analysts, on average, forecast earnings per share of US$4.59, data compiled by Bloomberg showed.

Amazon forecast operating income of between US$1.2 billion and US$2.9 billion in the fourth quarter compared with analysts’ estimates of US$4.31 billion.

Sales would be US$80 billion to US$86.5 billion in the holiday period, the company said. Analysts forecast US$87.2 billion.

Operating expenses during the third quarter climbed 26 percent, the steepest rise in more than a year, to US$66.8 billion. Shipping costs soared 46 percent to US$9.6 billion.

Delivery is hardly the only place Amazon is investing.

Amazon’s costs for technology and content — largely salaries related to employees in research and development, as well as infrastructure for Amazon Web Services (AWS) Inc data centers — jumped 28 percent to US$9.2 billion.

The company’s total workforce increased 22 percent to 750,000.

While the shares have gained 19 percent this year to close at US$1,780.78 in New York on Thursday, they have fallen 12 percent since the July 15 high of US$2,020.99.

Investors had bid up Amazon shares on growing profits driven by AWS, services for third-party sellers and advertising.

The cloud-computing unit remains Amazon’s cash cow.

Sales rose 35 percent to about US$9 billion in the third quarter. The unit’s operating income, US$2.26 billion, accounted for more than two-thirds of the total.

However, growth at AWS was the slowest since Amazon began breaking out the unit’s performance.

That is “absolutely” a concern for investors, D.A. Davidson & Co analyst Tom Forte said.