# How foundset.search() works?

**URL:** <https://forum.servoy.com/t/how-foundset-search-works/14119>\
**Category:** Classic Servoy\
**Created:** [June 9, 2011, 6:39pm UTC](https://forum.servoy.com/t/how-foundset-search-works/14119 "2011-06-09T18:39:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasantana](https://avatars.discourse-cdn.com/v4/letter/j/e79b87/32.png) [@jasantana](https://forum.servoy.com/u/jasantana)\
**Post date:** [June 9, 2011, 6:39pm UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/1 "2011-06-09T18:39:25Z")

</div>

I would like someone could clarify some points about the search() method.

Does it execute a SQL against the DB everytime it is used? Sometimes you have a foundset in memory, let´s say a short foundset like a temporary cursor in FoxPro, and you need to check the existence of a record and it is not necessary to search over the DB but just in the cursor you have in memory.

I can see that doing a search() filters the records in the foundset. Is there a way to just point to that record in the foundset and not filtering it?

Thanks.

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [June 10, 2011, 8:32am UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/2 "2011-06-10T08:32:49Z")

</div>

Juan,

foundset.search() always queries the database.  
When you have the record in a foundset you can use foundset.selectRecord(pk) to find it.

Note that Servoy loads the PKs of a foundset in chunks of 200.  
foundset.selectRecord does not query the database, but if the record does belong to the foundset, only the pk has not been loaded yet (when it belongs to the second chunk for example), then foundset.selectRecord(pk) cannot find it.

Rob

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 10, 2011, 9:42am UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/3 "2011-06-10T09:42:15Z")

</div>

> rgansevles:  
> Juan,
> 
> foundset.search() always queries the database.

Hmm, than why do we have to use sometimes the function: refreshFromDatabase, when there are new records, inserted outside Servoy?

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [June 10, 2011, 10:14am UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/4 "2011-06-10T10:14:54Z")

</div>

Harjo,

That is to update foundsets that are shown already and need to be notified of a change in the data.

Rob

---

<div class="post-metadata">

**Author:** ![stefanoni](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@stefanoni](https://forum.servoy.com/u/stefanoni)\
**Post date:** [October 19, 2011, 9:25am UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/5 "2011-10-19T09:25:44Z")

</div>

> rgansevles:  
> Harjo,  
> That is to update foundsets that are shown already and need to be notified of a change in the data.  
> Rob

Just to make it clear:

The change of date inside Servoy (even if its a other user) is always sent to the already shown foundset,  
by the Servoy-Databroadcasting.  
The manually refresh is only necessary ,if the data is changed **outside** of Servoy, for example,  
in the case of Foxpro is changing the dbf during servoy shows it in a foundset.

Is that true ?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [October 19, 2011, 12:56pm UTC](https://forum.servoy.com/t/how-foundset-search-works/14119/6 "2011-10-19T12:56:08Z")

</div>

yes
