laravel-oci8
laravel-oci8 copied to clipboard
Cache-size database connection oracle with error! Help-me!
Problem or Feature Request Summary
I want the primary key to be always incremented by 1 in ascending order for new inserts in the database.
My database has cache-size of 20, and with this setting when doing insert the primary key does not faithfully obey a growing order.
For what I researched, cache-size is responsible for perfomance, so I would not like to remove it.
It seems to me that the laravel application, rather than picking up the first ID in ascending order, takes any random ID at the time of generating Sequence (DB :: getSequence).
Help me find a solution please, I've already been 3 days with this problem!
System Details
- Operating System: Ubuntu
- PHP version: 7.1
- Laravel Version: 5.4
- Laravel-OCI8 Version: 5.4
It seems to me that the laravel application, rather than picking up the first ID in ascending order, takes any random ID at the time of generating Sequence (DB :: getSequence).
I think there is something wrong with your assessment (but I maybe wrong too). AFAIK, sequence will always increment to the next step value (default is step 1) every time you issue a nextVal sql. If you want it to increment properly, you need to make sure that all insert action you issue are correctly executed. Note that any failed insert execution will yield to an increment in the sequence current value which maybe the reason you think it's getting a random value?
The form of insertion is correct. When I give nextValue through the application it works correctly, incrementing one by one.
When the application is accessed the correct one is a cache of 20 ID's in the database. Each user (session) makes a nextValue and uses an ID incrementally. But it seems to me that the application is caching. That is, if there are 2 users (session), the cache is 20 for each, total 40 ID's. The problem with this is that the user does not use the ID's and there are gaps in ID's in the database.
Example with cache-size 5: user / session-1 - cache ID's 11, 12, 13, 14, 15. user / session-1 saved ID 11. user / session-2 - cache-size ID's 16, 17, 18, 19, 20. user / session-2 saved ID 16.
Database: ID ... 11 16 ...
GetSequence must be prevented from caching. But I have not figured it out.
I tried in many ways and could not use getSequence. I made a direct ID insert, where ID = select max (id) + 1.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.