Date query perfomance

Questions and answers regarding general SQL and backend databases

Date query perfomance

Postby robrecht » Tue Feb 26, 2013 10:46 pm

Hi,

I have attached a screenshot of performance data when loading 1 form.
4 queries are executed 882 times - which is normal - but 1 query is taking 8ms each time.
I see there is date comparison and also an 0R clause, so I suppose one of these is slowing it down.

In code this happens :

Code: Select all
   /** @type JSFoundset<db:/globis_development/stock_salesreservation> */
   var _fs_stock_salesreservation = databaseManager.getFoundSet("globis_development", "stock_salesreservation");
   _fs_stock_salesreservation.clear()
   _fs_stock_salesreservation.find()
   _fs_stock_salesreservation.warehouse_id = _warehouse_id   
   _fs_stock_salesreservation.article_stock_id = _article_stock_id
   _fs_stock_salesreservation.stock_salesreservation_status = _array_status
   _fs_stock_salesreservation.expected_delivery_date = '<=' + globals.svy_utl_dateFind(_date, true)   
   _fs_stock_salesreservation.order_on_hold = 0
   _fs_stock_salesreservation.contract_article_id = _contract_article_id ? _contract_article_id : '^'
   _fs_stock_salesreservation.newRecord()   
   _fs_stock_salesreservation.warehouse_id = _warehouse_id   
   _fs_stock_salesreservation.article_stock_id = _article_stock_id
   _fs_stock_salesreservation.stock_salesreservation_status = _array_status
   _fs_stock_salesreservation.backorder_delivery_date = '<=' + globals.svy_utl_dateFind(_date, true)   
   _fs_stock_salesreservation.order_on_hold = 0
   _fs_stock_salesreservation.contract_article_id = _contract_article_id ? _contract_article_id : '^'
   _fs_stock_salesreservation.search()


What can I do to boost the performance?

I think there are indeces where they are supposed to be

Thanks
Attachments
performance_data.PNG
performance_data.PNG (61.7 KiB) Viewed 2599 times
robrecht
 
Posts: 99
Joined: Wed Aug 01, 2012 4:30 pm

Re: Date query perfomance

Postby mboegem » Wed Feb 27, 2013 10:13 pm

Hi Robrecht,

hard to say what is causing the 8ms.
Although not much on it's own, it is when getting fired 882 times :)

Did you check your tables for in(correct) indices?

Other thing which might speed up things: try writing a custom query to load your data.
Maybe even show the results using a solutionModel with a custom dataSource.

Based on the info in your post it's still a big guess...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1752
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Date query perfomance

Postby rgansevles » Tue Mar 05, 2013 2:14 pm

Robrecht,

You could try create the query using QueryBuilder, the or-clause would be smaller.

Alternatively you could also run 2 queries.
Suppose the one on contract_article_id hits 90% of the time, the second one could be skipped.

Hope this helps,

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 13 guests