What is the most optimized method to Remove and Return the first element?
Closed this issue · 1 comments
LeMoussel commented
Hi,
What is the most optimized method to Remove and Returns the first element of the table stored at key like LPOP Redis Command.
I do this, but I have long processing time when there are lots of records
// create a new instance
SQLiteStorage<My_Class> db = new SQLiteStorage<My_Class> ("path_to_my_file.sqlite", SQLiteStorageOptions.UniqueKeys ());
db.Set ("key1", new My_Class ());
db.Set ("key2", new My_Class ());
db.Set ("key3", new My_Class ());
// ... save more items with associated keys
// Get the first element of the table.
// => long processing time when there are lots of records
var My_Class_Details = db.GetDetails().First();
// Remove this first element
db.Remove(My_Class_Details.Key);
khalidsalomao commented
Hi @LeMoussel ,
Sorry this helper doesn't implement a queue or work queue.
But the current implementation should be fairly performant even for this use case. Are you having issues with database performance?
I would suggest that in you code you use db.GetDetails (sortNewestFirst: false).First()
to use the primary key as the sort order. That should give you a marginal performance gain on the select phase.