sqlkata / querybuilder

SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
https://sqlkata.com
MIT License
3.09k stars 499 forks source link

PERF: PaginateAsync uses Count(*) to count number of rows #682

Closed binoypatel closed 1 year ago

binoypatel commented 1 year ago

Hi there,

Thanks for your great work. I am new to this library and using it first time in my project. I found that when I am using the following code: var result = await _db.Query("Customers") .OrderBy("Id") .Select("Id", "Name", "Tag") .PaginateAsync( 1, 10 ) .ConfigureAwait(false);

In the log, I can see that it uses SELECT COUNT(*) AS [count] FROM [Customers]

Would it be possible to change to COUNT(1) instead of COUNT(*)?

Kind regards, Binoy

nielslucas commented 1 year ago

Why would you need this? I did a 1 minute research (sorry, too lazy to do more) and found this:

https://stackoverflow.com/questions/1221559/count-vs-count1-sql-server

The answere: There is no difference.

For the record, not trying to attack you, just curious for the 'why'. Its always a good practise to supply a 'why' to a feature request.

binoypatel commented 1 year ago

Yes, you are right, both are the same and not require any change. Thanks for your quick findings.


From: Niels Lucas @.> Sent: Sunday, July 23, 2023 8:53:21 AM To: sqlkata/querybuilder @.> Cc: Binoy @.>; Author @.> Subject: Re: [sqlkata/querybuilder] PERF: PaginateAsync uses Count(*) to count number of rows (Issue #682)

Why would you need this? I did a 1 minute research (sorry, to lazy to do more) and found this:

https://stackoverflow.com/questions/1221559/count-vs-count1-sql-server

The answere: There is no difference.

For the record, not trying to attack you, just curious for the 'why'. Its always a good practise to supply a 'why' to a feature request.

— Reply to this email directly, view it on GitHubhttps://github.com/sqlkata/querybuilder/issues/682#issuecomment-1646833390, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABEFY3DRY7HWXUWGXXP7OODXRUNEDANCNFSM6AAAAAA2K24T5Y. You are receiving this because you authored the thread.Message ID: @.***>