0

Anyone knows why the entity_id in sales_flat_order table jumps as opposed to be sequentially incremented?

mysql> SELECT entity_id FROM sales_flat_order;
+-----------+
| entity_id |
+-----------+
| 1         |
| 8         |
| 13        |
+-----------+
3 rows in set (0.00 sec)
user2395853
  • 89
  • 1
  • 9
  • It's because of mysql ROLLBACK in Magento innodb database. Mostly when payment validation fails while create other than rollback occur in order data. – himansu Aug 23 '17 at 18:03

2 Answers2

1

(reply form the future)

This might be caused by DB Transactions involving order entities creations being rolled-back

MySQL AUTO_INCREMENT does not ROLLBACK

Francesco Salvi
  • 306
  • 3
  • 9
0

When Magento enters the checkout process it 'reserves' an increment_id and places it on the quote (cart) object. You can see the code that gets an increment id at:

Mage_Eav_Model_Entity_Type::fetchNewIncrementId()

This behaviour exists to allow Magento to send payment gateways the final order id (increment_id), before the order is completed allowing the gateway to associate the order id with the order. If the customer abandons the payment process in the gateway.

If you want to find your 'missing' increment_ids, take a look in sales_flat_quote under the field reserved_order_id. You should see them attached to unconverted quote objects.

There is nice answer here. magento order id increment jumps

Community
  • 1
  • 1
Mufaddal
  • 5,398
  • 7
  • 42
  • 57
  • Thank you. However, I do know why Magento Order ID (aka increment_id in the database) jumps. I've read that post before I posted this question. if you really look at the reserved_order_id field, you'll see that it is the increment_id (i.e 100000003) not the entity_id. The one I asked is **entity_id** not increment_id. – user2395853 May 18 '13 at 18:22