Trace: undocumented_preparedstatement_optimization

Table of Contents


Undocumented PreparedStatement optimization

We just get a 20% response time gain on a 600+ lines query under Oracle. Our DBA noticed that queries were faster when launched from SQLDeveloper than from our JEE application using the JDBC Oracler 11g driver. We looked at the queries as they actually arrived to the Oracle engine and they where under the form : SELECT… WHERE col1 like ':myvar1' OR col2 LIKE ':myvar2' AND col3 IN (:item1,:myvar2,…) and not 'SELECT… WHERE col1 LIKE ':1' OR col2 LIKE ':2' AND col3 IN (:3,:4,…) like usual when using PreparedStatement the regular way.

Indeed, every PreparedStatement documentation I'm aware of, beginning with the one from Sun states that we have to use '?' to represent bind variables in queries. These '?' are replaced by ':1', ':2', '3' … by the JDBC driver. So the database has no way to now in our case that :2 and :4 have the same value. This information is lost.

We discovered that we can use PrepareStatement by providing queries with named bind variables instead of '?'. Of course, we still have to set the right value using the setXXX(int position,value) setters for every bind variable occurrence in the query. Then, queries arrive to Oracle like when using SQLDeveloper, with named bind variables.

OK but what's the deal with all this ?

I'm not sure but I think that this optimization may allow Oracle optimizer to be cleverer, especially for queries with redundant parts. It is especially good for queries with duplicated sub SELECT with IN condition containing all the same list of items. Maybe Oracle create on-the fly WITH clauses or similar optimizations in this case ?

Note that this optimization may only work with Oracle and is probably only useful for very large or redundant queries. I don't recommend it in most cases. AFAIK, neither Hibernate nor Spring-JDBC implements this optimization.

tag

Discussion

cara jitu menyembuhkan radang ususcara jitu menyembuhkan radang usus, 2016/06/28 10:14

His form has been filled. Thank you friend b(^) http://www.obattbctradisional.com/cara-jitu-menyembuhkan-radang-usus/

CREAM yashodaraCREAM yashodara, 2016/07/08 07:24

http://www.ernaherbal.com/ http://www.ernaherbal.com/cream-wajah-merek-yashodara/ http://www.ernaherbal.com/pearl-powder-capsule-woo-tekh/ http://lapakaku.com/ http://lapakaku.com/cream-yashodara-0858-4621-1788/ http://www.apotikherbalonline.com/ http://www.apotikherbalonline.com/amankah-cream-wajah-yashodara/ http://www.jellygamatqncaslipusat.com/ http://www.jellygamatqncaslipusat.com/harga-fair-n-pink-body-serum-2016/ http://www.jellygamatqncaslipusat.com/fair-n-pink-serum-pemutih-badan-terbaik/ http://www.jellygamatqncaslipusat.com/efek-samping-fair-n-pink-body-serum/ http://www.jellygamatqncaslipusat.com/distributor-resmi-fair-n-pink/ http://www.creamyashodara.net/ http://www.creamyashodara.net/info-harga-cream-pemutih-wajah-yashodara/ http://www.creamyashodara.net/cream-wajah-yashodara-asli/ http://www.yashodaracream.com/ http://www.yashodaracream.com/cream-yashodara-0858-4621-1788/ http://www.yashodaracream.com/jual-cream-yashodara-jakarta/ http://www.yashodaracream.com/distributor-resmi-cream-yashodara/ http://www.yashodaracream.com/krim-pencerah-wajah-yang-bagus-dan-aman/ http://www.yashodaracream.com/jual-cream-pemutih-wajah-aman-yashodara/ http://www.yashodaracream.com/testimoni-pengguna-cream-yashodara/ http://www.yashodaracream.com/cream-pemutih-wajah-yashodara-yang-asli/ http://www.yashodaracream.com/manfaat-yashodara-whitening-cream/ http://www.yashodaracream.com/cream-penghilang-flek-hitam-terbaik-dan-aman/ http://www.yashodaracream.com/cream-pemutih-wajah-yang-bagus-terdaftar-bpom/ http://www.yashodaracream.com/yashodara-cream-untuk-menghilangkan-flek-hitam/ http://www.yashodaracream.com/harga-yashodara-whitening-cream/ http://www.yashodaracream.com/yashodara-cream-pemutih-wajah-cepat-dan-aman/ http://www.fairnpinkserum.yashodaracream.com/ http://www.fairnpinkserum.yashodaracream.com/agen-fair-n-pink-surabaya/ http://www.fairnpinkserum.yashodaracream.com/agen-serum-pemutih-fair-n-pink-bandung/ http://www.fairnpinkserum.yashodaracream.com/serum-pemutih-badan-tercepat-fair-n-pink/ http://www.fairnpinkserum.yashodaracream.com/harga-fair-n-pink-asli-murah/ http://www.fairnpinkserum.yashodaracream.com/testimoni-pengguna-fair-n-pink-body-serum/ http://www.fairnpinkserum.yashodaracream.com/manfaat-serum-fair-n-pink/ http://www.fairnpinkserum.yashodaracream.com/fair-n-pink-glutathione-body-serum/ http://www.fairnpinkserum.yashodaracream.com/lotion-pemutih-badan-permanen-terdaftar-di-bpom/ http://www.fairnpinkserum.yashodaracream.com/jual-fair-n-pink-body-serum-asli-murah/

JAMKHO OBAT KOLESTEROLJAMKHO OBAT KOLESTEROL, 2016/07/08 11:20

http://www.obatkolesteroltinggijamkho.com/2016/06/obat-penurun-kolesterol-yang-aman.html http://www.obatkolesteroltinggijamkho.com/2016/05/merk-obat-kolesterol-yang-bagus.html http://www.obatkolesteroltinggijamkho.com/2016/05/obat-kolesterol-yang-dijual-bebas.html http://www.obatkolesteroltinggijamkho.com/2016/04/jamkho-herbal-kolesterol-aman-untuk.html http://www.obatkolesteroltinggijamkho.com/2016/03/obat-encok-yang-ampuh.html http://www.jamsiobatpenyakitgula.com/2016/06/jual-jamu-diabetes-jamsi-di-bandung.html http://www.jamsiobatpenyakitgula.com/2016/03/jual-jamsi-harga-murah.html http://www.jamsiobatpenyakitgula.com/2016/03/testimoni-pengguna-jamsi.html http://www.obatherbalkolesteroll.com/2016/04/jamkho-obat-kolesterol-aman-untuk.html http://www.obatherbalkolesteroll.com/2016/03/efek-samping-maderic.html http://www.obatherbalkolesteroll.com/2016/03/obat-asam-urat-maderic.html http://www.obatkolesteroll.com/2016/05/jamu-untuk-menurunkan-kolesterol-paling.html http://www.obatkolesteroll.com/2016/05/obat-kolesterol-paling-bagus.html http://www.obatkolesteroll.com/2016/04/jamkho-untuk-menurunkan-kolesterol.html http://www.obatkolesteroll.com/2016/03/maderic-obat-sakit-sendi-lutut.html http://www.maderikobatasamurat.com/jual-maderic-di-bandung/ http://www.maderikobatasamurat.com/bitter-melon-softgel-woo-tekh/ http://www.maderikobatasamurat.com/obat-kaki-kesemutan-dan-pegal/ http://www.maderikobatasamurat.com/obat-rematik-yang-manjur/ http://www.maderikobatasamurat.com/maderic-obat-asam-urat/ http://www.obatkolesterol.kaisarherba.com/harga-jamkho-obat-kolesterol-terbaru-2016/ http://www.obatkolesterol.kaisarherba.com/ramuan-herbal-untuk-menurunkan-kolesterol/ http://www.jamkhoobatkolesterol.com/2016/06/cara-membeli-jamkho-asli-dengan-harga.html http://www.jamkhoobatkolesterol.com/2016/05/nama-obat-penurun-kolesterol-yang-bagus.html http://www.jamkhoobatkolesterol.com/2016/05/obat-nyeri-pundak-dan-punggung.html http://www.jamkhoobatkolesterol.com/2016/04/bahaya-kolesterol-tinggi-yang-perlu.html http://www.jualjamkhoherbal.com/jual-jamkho-di-kota-surabaya/ http://www.jualjamkhoherbal.com/batas-normal-kolesterol-dalam-darah/ http://www.krimwajahaman.com/2016/05/cream-wajah-yang-ampuh-menghilangkan.html http://www.krimwajahaman.com/2016/05/testimoni-cream-wajah-woo-tekh.html http://www.krimwajahaman.com/2016/05/cara-menghilangkan-bekas-jerawat-dengan.html http://www.krimwajahaman.com/2016/03/collagen-softgel-woo-tekh-pemutih-kulit.html http://www.krimwajahaman.com/2016/03/cara-mengatasi-kulit-kering-dan-kusam.html http://www.creamwajahyangalami.com/2016/05/whitening-woo-tekh-cream-untuk.html http://www.creamwajahyangalami.com/2016/05/testimoni-whitening-freckle-cream-woo.html http://www.creamwajahyangalami.com/2016/05/cara-merawat-kulit-wajah-agar-awet-muda.html http://www.creamwajahyangalami.com/2016/04/cream-untuk-menghilangkan-noda-hitam.html http://produkwootekh.planet-herbal.com/harga-cream-wajah-woo-tekh/ http://produkwootekh.planet-herbal.com/cream-pemutih-wajah-tanpa-pengelupasan/ http://produkwootekh.planet-herbal.com/cara-mengencangkan-kulit-wajah-yang-kendur/ http://creamwajahwootekh.planet-herbal.com/harga-whitening-freckle-cream-woo-tekh/ http://creamwajahwootekh.planet-herbal.com/cream-pemutih-wajah-tanpa-merkuri/ http://creamwajahwootekh.planet-herbal.com/obat-untuk-memutihkan-seluruh-badan/ http://creamwajahwootekh.planet-herbal.com/cara-menghilangkan-bintik-hitam-di-wajah/ http://www.wscbioloslimming.net/2016/06/green-world-slimming-capsule-obat.html http://www.wscbioloslimming.net/2016/05/gwsc-obat-pelangsing-begini-cara.html http://www.wscbioloslimming.net/2016/05/obat-pelangsing-yang-cepat-menurunkan.html http://www.wscbioloslimming.net/2016/05/reaksi-awal-konsumsi-slimming-capsule.html

Enter your comment. Wiki syntax is allowed:
 
blog_tech/5/undocumented_preparedstatement_optimization.txt · Last modified: 2015/04/06 21:11 by bflorat