-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Configuring parameter markers
PostPosted: Wed Nov 05, 2008 5:25 am 
Beginner
Beginner

Joined: Thu Jul 24, 2008 3:33 am
Posts: 20
Hello!

I would like to ask you for your opinion to a certain problem we encountered and would like to know how I can solve this with hibernate.

We have a timestamp-field (the name is "replaced") in some tables which has the information "is valid until".
When the data record is valid (actual), the value of this field is "9999-12-31 23:59:59:999999" (means indefinitely).
When the data record is invalid (historic), the value of this field is a concrete timestamp.

Now the table has 50.000.000 entries and 30.000.000 entries have the value "9999-12-31 23:59:59:999999", which are 60%.
The database is DB2. There is an index on the column, so DB2 knows the n most used values (this is maintained via the command "runstats").

When a statement retrieves more than 10% of the entries from a table, an index scan is inefficient. Instead the database should use a table scan.
Therefore it is ideal if the database knows the values from an index (it does) and judge for each statement, if it should use an index or a table scan.

When I perform a SELECT with parameter marker via JDBC and I am using the column "replaced" in a where-statement,
the value "9999-12-31 23:59:59:999999" is replaced with a parameter marker. DB2 doesn't know the concrete value now and decides for an index scan.
The performance is not useable. When searching for a concrete value for the column "replaced", the performance is optimal.

When I perform a SELECT without parameter marker via JDBC and I am using the column "replaced" in a where-statement,
the value "9999-12-31 23:59:59:999999" is NOT replaced with a parameter marker. DB2 knows the value and decides for a table scan.
The performance is ok. When searching for a concrete value for the column "replaced", the statement is not cached, so the performance is good but not so good as with parameter marker.

So the ideal strategy is to use a parameter marker for the column replaced, when there is a concrete value and
not to use a parameter marker for default values ("9999-12-31 23:59:59:999999").
We have tested with other columns also and got the best performance when using parameter markers only on certain columns.

What I would like to know:
Does anyone have similarly problems with parameter marker and how do you deal with it?
Can Hibernate configure the use of parameter marker on certain columns (usage on/off)?
Can I provide my own SQL generation class?

Thanks in advance,
CL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 5:42 am 
Beginner
Beginner

Joined: Thu Jul 24, 2008 3:33 am
Posts: 20
It seams that I have to reduce my questions :-)

So I would only like to ask:
Is it possible to provide my own SQL generation class?

Thanks in advance, CL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2009 4:35 am 
Beginner
Beginner

Joined: Thu Jul 24, 2008 3:33 am
Posts: 20
Just wanted to give another try:
Is it possible to provide my own SQL generation class or to tweak SQL generation?

Thanks in advance, CL


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2009 5:10 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
u may write ur own find() in session for retrieving objects from session by redefining find() in Session class.

u wan't have any technique to write own SQL generation..

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.