aarondfrancis / fast-paginate

A fast implementation of offset/limit pagination for Laravel.
MIT License
1.21k stars 56 forks source link

Make it possible to run the pagination-query as one sql-query #25

Closed crissi closed 1 year ago

crissi commented 2 years ago

I can see that you use two queries for compatible with all sql databases.

Would it be possible to add a config option to enable to include it as a sub query as in the example in the readme?

I am running sql server which support this.

It seems in my setup with an sql server that most gains are lost when running two queries and actually slower in most scenariouses.

I can give it a try if you think this makes sense

aarondfrancis commented 2 years ago

For sure! If you want to take a stab at a PR I would love that. I don't have much SQL Server experience so that's nice to know it supports limits in subqueries!

crissi commented 2 years ago

I was trying this query on

select * from demo -- The full data that you want to show your users. where demo.id in ( -- The "deferred join" or subquery, in our case. select id from demo -- The pagination, accessing as little data as possible - ID only. limit 15 offset 5
)

on https://sqliteonline.com/ and all of theme seems to support the internal format

But they are running MariaDb here which might different from the mysql you have been running

aarondfrancis commented 1 year ago

I think I'm going to close this for now, I don't have plans to support this at the time.

I'll reopen if that changes!