with clause


Posted on 16th Feb 2014 07:03 pm by admin

hi all, i have a big query that usually access the same table more than once. for example, i have something like this

select
from table1 where id = 124
Did you know?Explore Trending and Topic pages for more stories like this.
union all
select
from table2 a, (select * from table1 where id 123) b
where a.id=b.id
union all
select
from table3 a, (select * from table1 where id = 345) b
and a.id=b.id

as you can see table1 is part of every union. the problem is that table1 is a huge table retrieving about 11 million records. accessing this table multiple time is hurting performance. i tried using With clause when i look a the explain plan the number of bytes is about 15 g

my question is how can i re-write the above query without accessing the table1 multiple times like i am in the code above.
if i use the with clause, the explain plan show big chuck of memory been use. thanks
No comments posted yet

Your Answer:

Login to answer
306 Like 47 Dislike
Previous forums Next forums
Other forums

PHP Surveys
I really would like some advice.

If you have a client come to you asking for a survey to be d

mysql select query problem
how can i select multiple fields from multiple table in one query like

i have table name t1 a

Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can di

MFC GUI Programming
I am working on a project right now that requires me to create a MFC Windows GUI. Basically it need

mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???

this is the code i got

Header redirect
Hello ive got a problem ive got form with its action set to itself.
Code: <form id="f

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as

Production of mango in processing industry
Hi,

We have one scenario ,company is in process industry,they are manufacturing MANGO pul

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash