Reputation: 1
I'm using splunk. Postgres SQL.
I have 2.1M rows to pull up in ASC order.
This is my standard query that is working:
WHERE we_student_id = 5678
ORDER BY audit.b_created_date DESC NULLS LAST
then I usually use: (if data is more than 1-2M. I split them into batches)
FETCH FIRST 500000 ROWS ONLY
OFFSET 500000 ROWS FETCH NEXT 500000 ROWS ONLY
this time, my client requested to extract them by ASC order based on audited id not audit_created_date.
I used:
WHERE student_id = 5678
ORDER BY audit.audited_id ASC NULLS LAST
==========
I tried to pull up the first 500k.
I used:
*ORDER BY ASC NULLS LAST
LIMIT 500000 OFFSET 0*
The result is just 100k.
I tried to put maxrows=0 before my select statement with the same query
*ORDER BY ASC NULLS LAST
LIMIT 500000 OFFSET 0*
but I'm getting an error: canceling statement due to user request.
I tried this query to get the first 400k instead of 500k and removed the OFFSET 0. And I'm still using maxrows=0
before my select statement
*ORDER BY ASC NULLS LAST
LIMIT 400000*
There's a result 400k.
When I tried to extract the next 400k, I queried
*LIMIT 400000 OFFSET 400000*
I encountered the error again: canceling statement due to user request.
Usually, I can pull up 2M rows on Database. I usually use "FETCH FIRST 1000000" Then offset the other batch. My usual query on DB is
ORDER BY DESC NULLS LAST
and use FETCH first and OFFSET
But this time, my client wants to get the data by ASC order.
I tried FETCH FIRST 400000 ROWS ONLY
query and there's a 400k result. but whenever I increase the number to 500000, I get this error: canceling statement due to user request.
I usually use maxrows=0
because Splunk only shows the first 100k rows. Most of my data are 1-2 Million.
This error only happened when the client requested the reports by ASC order.
I just want to pull up the 2.1M rows on the database and I don't know how to pull it up by ASC order. I don't know if I'm using OFFSET and LIMIT correctly.
Upvotes: 0
Views: 296