-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OFFSETs >1000 fail to return anything #126
Comments
Cursors are MUCH cheaper than offsets. I strongly recommend changing. Also, there might be a 1000 bug... Do do with default page sizes. I'll look On Saturday, 9 July 2016, Tristan Sokol [email protected] wrote:
Tom Walder, CTO |
Can you try something like this: $results = $obj_store->query("SELECT * FROM Artists");
if (!is_null($results))
{
$page_results = $results->fetchPage(1, $offset);
foreach ($page_results as $page_result)
{
// first_name is an example as I don't know your schema
echo $page_result->first_name;
}
} |
Experts, --Code-- The above code fetches fine until the offset of 1000, but after that it fails.. can someone help me, if I have more than 1000 records, whats the best way ? and whats the function I need to use. Tom says, use Cursors, what I should use from the library ? I understand Fetchall has that 1000 limitation. Appreciate your help! |
Not sure why this returns only 20 as count --but I have more than 900 records. $obj_schema = new GDS\Schema('xxaas'); $arr_subs = $obj_store_ns->fetchAll("SELECT * FROM xxaas where createdby='6229999BK9999ADMIN' ); --what am I doing wrong ? my understand is that FetchAll should return max of 1000 records. |
Is there any help/pseudocode that uses Cursors as Tom suggests? I need this for navigating more than 1000+ records (UI has Next and Previous). |
I think all I need to know is how to use this Query and FetchPage by passing Cursors. so using this (I could go only far with Fetchpage - pasted the code above) but got stuck how to pass as Cursors. if anyone can help me with that cursors that would be of great help. This is blocking totally :( |
BTW I was looking at your code and I notice you have while($arr_page = $results->fetchPage(100,1000)) and that means after the record 100 bring the next 1000. I was under the impression that wanted something like: while($arr_page = $results->fetchPage(1000,100)) Did I get it right? |
Hi Emilorol -- so this is how I tested. This will print 20 records at an offset of 10. so what I need is I want to pass something like "show 100 records, offset by 1100") |
Tristan gave a glimpse of that Cursor code, Now I just need to know how to Pass the Cursor variable to the FetchPage. $obj_store->setCursor(rawurldecode($_GET['albumoffset'])); |
Okay-- I tried with this below code and works fine as long as you don't pass the Cursor variable. So as soon as I pass the SetCursor Variable to fetchPage(5 , 'cur1') it gives me error.. The strange part is if I pass 5, it gives me 5 records...but if I pass 2000 it gives me only 300 records. ---Code---- |
Hi there, "Cursors" are not strings that you should set arbitrarily - they are generated by Datastore in response to getting a page of data, so you know where to pick up again for the next page. Please also see this note regarding supplying your own LIMIT parameter and how it may cause problems Would you like some "general" paging examples? I can put some together. Tom |
Paging examples on saving/setting the cursors would be appreciated! |
Hi Tom,
so I just need a loop/foreach or anything that will work fine for any number of records. The resultset will never return more than 50 per call. Below code works return 50 records and an offset of 2. but I need to implement using Cursors, so I don't get into this READS/COST/performance problem as you suggested. so if you can translate this code into a way so it uses Cursors, that would be awesome. $showingcount=0; } |
Hey Guys, For the first time call, you would simply query, Fetchpage, and then use GetCursor. $page_results= $obj_store_ns->query("SELECT * FROM logs where createdby='XXX' ORDER BY createdon desc"); The callout is, you need to have the composite index in place and its' better (at-least for me) to convert the getcursor to HexStrings and then Cache but for sure, better than offset. (particularly if you are using for Mobile Apps) Cheers and Thanks everyone for your support. |
hi to all, can someone give a full sample ? b.t.w - great work Tom, thank you for this GDS library !!! |
I have a page that executes a query does some stuff with the results and then refreshes while changing an URL parameter that increases the offset of the query.
I was using queries like
SELECT * FROM Artists LIMIT 1 OFFSET 523
with FetchAll() but they started returning empty at 1001. I can query my admin interface with the same querySELECT * FROM Artists LIMIT 1 OFFSET 523
and get the expected result. I have also tried the same general premise with FetchPage(1).I'm going to try to extract the cursor and pass that between pages.
The text was updated successfully, but these errors were encountered: