getFoundSetCount vs getFoundSetDataProviderAsArray

Questions, tips and tricks and techniques for scripting in Servoy

getFoundSetCount vs getFoundSetDataProviderAsArray

Postby paulc » Fri Sep 10, 2010 12:31 am

Hi all,

I am having huge performance issues when using databaseManager.getFoundSetCount or databaseManager.getFoundSetDataProviderAsArray.

I have a foundset with over 5000 records, and I need to get the foundset count quickly.

When using either databaseManager.getFoundSetCount /databaseManager.getFoundSetDataProviderAsArray its taking over 1 minute to return a count.

What might be the fastest method in which to return a count on a large foundset?

thank you
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: getFoundSetCount vs getFoundSetDataProviderAsArray

Postby ROCLASI » Fri Sep 10, 2010 12:48 am

Hi Paul,

Using databaseManager.getFoundSetDataProviderAsArray() will give you an array of your 5000 records of a specific column. So this is a very expensive action.
databaseManager.getFoundSetCount(foundset) is the preferred way to get a total count of your foundset.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: getFoundSetCount vs getFoundSetDataProviderAsArray

Postby pbakker » Fri Sep 10, 2010 9:27 am

And databaseManager.getFoundSetCount() lets the database sort out how many records there are, so it's the fastest way possible. If it's not performing, you should have a look at the Performance log on the admin pages to see the query being fired and then see if the database can be optimized (by adding indexes) to give you the result faster.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Re: getFoundSetCount vs getFoundSetDataProviderAsArray

Postby paulc » Mon Sep 20, 2010 9:34 pm

Hi Paul / Roclasi

Thanks for the input. After trying many different methods, you are both correct in the fact that databaseManager.getFoundSetCount() is the fastest possible method in which to get a foundsets count. I was just hoping there was something that cmight be less expensive. We utilize this call in numerous places in our code, and depending on the size of the foundset, it can slow our system down quite significantly.
paulc
 
Posts: 55
Joined: Wed Feb 17, 2010 8:58 pm

Re: getFoundSetCount vs getFoundSetDataProviderAsArray

Postby Harjo » Mon Sep 20, 2010 10:21 pm

let me get this straight! getFoundSetCount will take 1 minute with only 5000 records?? :shock:
which database are you using? there must be something wrong. We use it also a lot, with MANY MANY more records...
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: getFoundSetCount vs getFoundSetDataProviderAsArray

Postby rgansevles » Tue Sep 21, 2010 8:12 pm

Paul,

databaseManager.getFoundSetCount() does no more then taking the query from the foundset (select pk from table where ...) and converts it to a select count (select count(1) from table where ...).
In case of joins (for example when you have a related search condition), a distinct(pk) is added.

What shows on top in the admin page->performance data when you run the foundsetcount?

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


Return to Methods

Who is online

Users browsing this forum: No registered users and 13 guests

cron