Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

read multiple by ID always go to the external data source problem

Hi,

I try using Read-Through via the Near cache - do not know if that is relevant but just to explain the background.

Read through works just fine: for the first time the object with the ID is missing in the cache the external data source is used and on the subsequent requests the object gets returned either from near cache or from ?master? node.

This works finw: space.read(new ReferenceStyleExt(id), null, Lease.FOREVER);

<gigaspaces-mapping> <class name="cblt.inventory.service.space.vo.ReferenceStyleExt" persist="true" replicate="true"> <property name="chromeStyle" index="none"/> <property name="chromeHistStyleId" index="none"/> <property name="version" index="none"/> <version name="version"/> <id name="chromeHistStyleId" auto-generate="false"/> </class> </gigaspaces-mapping>

Now there is fun part:

If I do readMultiple and I still want to retrieve all the objects by their IDs as following:

    Object[] objects = space.readMultiple( (Object)new SQLQuery( new ReferenceStyleExt(), ?chromeHistStyleId in (?aa?,?bb?)?, null, 2);

the space does not pay attention at availability of the objects with the given IDs in the space already and goes to external data source to retrieve the objects.

Another strange thing is that Space calls iterator method on the external data source for every ID passed, it does not pass all the parameters, but one by one with the request:

SELECT * FROM cblt.inventory.service.space.vo.ReferenceStyleExt WHERE chromeHistStyleId = ?

so I do not understand the following: - why it tries to retrieve objects by id again if object with the ID is already available in the space? Is this normal? I would expect that to be the case only for IDs not in the space. - why it passes only one parameter at the time and not the whole query?

The difference in performance is quite dramatic as you could imagine - milliseconds to retrieve objects from the space and minutes from database. I was trying to improve the milliseconds by eliminating latency of one-by-one calls, and instead readMultiple brings the whole system to the knees.

Is there a way to retrieve multiple elements from the space by ID when read through pattern is used so only elements not present in the space will be retrieved from the external data source?

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=1945]{quote}

asked 2008-03-21 16:58:56 -0500

kgignatyev gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

The OR based query is broken down into multiple ExternalDataSource requests by the space query processor to optimize the processing within the space.
See details here:
http://www.gigaspaces.com/wiki/display/OLH/JavaSpacesAPIRead-Through#JavaSpacesAPIRead-Through-ReadingMultipleObjectsUsingSQLQuery
See the Understanding How a Query is Handled section.
The AND based query will not be broken down.

Using readMultiple by nature with ExternalDataSource is not that straightforward.
If you don?t know how many objects exists within the space that match your query criteria you will need to access the database with any readMultiple call.

With your specific case , I suggest you for now to perform multiple separate read calls. This will also optimize the access with the local cache.

We will enhance this mechanism in the future.

Shay

answered 2008-03-22 06:16:39 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-03-21 16:58:56 -0500

Seen: 44 times

Last updated: Mar 22 '08