Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Prepared Statements, parameterized table names?  RSS feed

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I understand that using parameters for queries helps the DBMS to reuse optimization plans.
A query like
select * from x where y= ?

is better that "select * from x where y= 10"

My question is, is the optimization plan reusable for different tables..

like select * from ? where y=?.

Thanks
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandana,

The optimiser would have to generate a new query plan for each table. One reason for this is that different tables may have different indexes so the method of accessing the data may be different. Even if the indexes, etc. were all the same on different tables, the optimised query plan only provides a template for substitution of values.

The same query using different values can be executed the same way. The same query using a different table must be executed differently (i.e. on a different table! )

Jules
 
chandana sapparapu
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julian,
Thanks for the reply. I also had a feeling that it varies from table to table, but just wanted to confirm it. Thanks for the details .

Regards
 
Everybody's invited. Even this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!