how can i order in db
See original GitHub issueHi : Mauricio thanks for your project first . i have a doubt that why there is no order in Find
IEnumerable<T> Find(Query query, int skip = 0, int limit = int.MaxValue)
for example , i want take latest 100 docs , i have a field “AddedTime” the normal way is order by AddedTime desc then skip 0 and take(limit) 100 ,that’s what i needed . but without order ,the take is no sence .
what should i do ?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to store ordered information in a Relational Database
A column called order , which is a decimal ( NUMERIC ). When a song is moved, it is assigned the floating point...
Read more >Storing item positions (for ordering) in a database efficiently
Store the order linked-list style. Instead of saving the absolute position, save the ID of the previous item. That way any change only...
Read more >SQL ORDER BY Keyword
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword....
Read more >How to Order Alphabetically in SQL
If you want to select records from a table but would like to see them sorted according to a given column, you can...
Read more >ORDER BY - MariaDB Knowledge Base
Use the ORDER BY clause to order a resultset, such as that are returned from a SELECT statement. You can specify just a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @178220709,
If you want take your lasted 100 docs using indexes, you can:
AddedTime
Now you will list all yor documents in
AddedTime
desc order and get only 100 first.You right, local db has no network and all operations must be executed in local machine.
The only optimization that can be do it is filter. So,
Find
operation use indexed document field. This is valid optimation. When you useQuery.All
and than implement aWhere
linq, it´s more expensive because you need read all data pages and deserialize all documento only to know if match with your clause.So, my recomendation is: always use
Find
(when possible) and then use normalLinq
implementation.