Elequent lazy and chunk method make data duplicate #52913
Replies: 12 comments 2 replies
-
How are your results ordered? What exactly is |
Beta Was this translation helpful? Give feedback.
-
Also despite of some rows are duplicate, the real number of rows was not changed, instead some real rows was lost. |
Beta Was this translation helpful? Give feedback.
-
My apologies, meant to ask how is your query ordered. Could you perhaps show us the query - possibly via |
Beta Was this translation helpful? Give feedback.
-
here is query:
I just changed table names and field names. |
Beta Was this translation helpful? Give feedback.
-
Interesting, so it is not just a model query, this more than that. Is Could, perhaps, ordering by ID help? Did you try |
Beta Was this translation helpful? Give feedback.
-
No it is not depend on Inner join, firstly I checked this. when I use |
Beta Was this translation helpful? Give feedback.
-
I used |
Beta Was this translation helpful? Give feedback.
-
Have you tried using Reference: https://laravel.com/docs/10.x/queries#streaming-results-lazily Also, Laravel 10.x is unsupported, do you know if the issue is still present on Laravel 11.x? |
Beta Was this translation helpful? Give feedback.
-
Mind that |
Beta Was this translation helpful? Give feedback.
-
I think this is not fit using with joined tables. I use this
And I can not use just |
Beta Was this translation helpful? Give feedback.
-
Can you try qualifying the column using an $this->query->addSelect([
new \Illuminate\Database\Query\Expression('auto_payments.id AS sort_id')
])->lazyByIdDesc(200, 'sort_id') You can also use the |
Beta Was this translation helpful? Give feedback.
-
Hi, we had the same issue in downloading big volume data and we solved it with cursor just like @normatov07 said here #52913 (comment) . The issue was the data was changing while the download in chunks was happening so it resulted in duplicates while using pagination(simple or length aware). The cursor paginator (after we fixed it) worked. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
10.10
PHP Version
8.2
Database Driver & Version
PostgreSql 16
Description
I am trying to export my data from postgresql to excel and I have huge data to export so I need to used laravel lazy collection. but I noticed some strange results. My some real rows are lost and instead some other rows is duplicated or even threefolded.
Steps To Reproduce
I am trying to export my data from postgresql to excel and I have huge data to export so I need to used laravel lazy collection. but I noticed some strange results. My some real rows are lost and instead some other rows is duplicated or even threefolded. Then I use chunk method but result was the same. then I get all data using get() method and I saw my real data successfully, nothing is changed.
Here is my code which I used:
Beta Was this translation helpful? Give feedback.
All reactions