Technology : General Technology Notes: Diary of a late,late adopter.
Updated: 8/14/2003; 1:41:06 AM.

 

Frequent Visits
Categories

Subscribe to "Technology" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Friday, March 14, 2003

This is really simple, but simple is what I am all about.  When using SELECT DISTINCT from huge tables with many joins, it forces a full table scan and can slow down a query. 


SELECT DISTINCT blah blah blah blah blah blah blah

FROM A,B,C

WHERE A.CUST_ID = B.CUST_ID

AND blah blah blah blah blah

AND blah

Would be inefficient

To get around this put the distinct on the outside of a subquery:

Select Distinct blah, blah, blah, blah

FROM

(SELECT blah, blah, blah, blah, blah, blah, blah,

FROM A,B,C

WHERE A.CUST_ID = B.CUST_ID

AND blah AND blah AND blah 

AND blah )


4:05:18 PM    comment []

Exporting Files from Toad. 

  1. Toad brings the query results to your desktop. This can be a bad thing if it is a huge query and you need a few tries to get it right. Toad will hog your system resources while it imports all the data from the query. It can be a good thing in that when you go to export the data to a file, it doesn't require another query.
  2. When saving to a delimited file, use the SaveAs feature available from right clicking on the result grid. If you check "include null text" any field with no value will show up with the word 'null' in it. If you are doing mailing labels, this is not good.
  3. Tab delimited format seems to have been the safest for me. Comma delimited gave me big problems if there was a stray comma in any text values in the result set.
    3:55:14 PM    comment []

© Copyright 2003 mcgyver5.



Click here to visit the Radio UserLand website.

 


March 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Feb   Apr