Query tuning with tablename alias
Title: Message Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an applicationthat generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE.SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Arethere any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred toby alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper
RE: Query tuning with tablename alias
Wendy - I think the difference between using an alias or not is negligible. My reasoning is that this would be easy to test (good idea if you have a moment) and there are enough picky Oracle developers that if this was not negligible, people would have been bragging about this as their secret method to make their application faster, and some vendors would be selling SQL pre-processors that would allow you to use aliases without penalty. So I wouldn't worry about it, but you are welcome to test this and if you can find a difference, we would all be glad to hear about it. It has happened before, where everyone has assumed they knew the answer and later it turned out that something simple was a bad assumption. Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] -Original Message- Sent: Wednesday, November 20, 2002 12:13 PM To: Multiple recipients of list ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: DENNIS WILLIAMS INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: Query tuning with tablename alias
Wendy, I have never heard of alias' providing either a performance gain or reduction. One thing I haven't verified though is the impact on hints. It has been my observation that if a table has an alias then that alias must be used in the hint. For example: select /*+ index(user) */ * from ctcs_user u; Does not use an index, whereas: select /*+ index(u) */ * from ctcs_user u; Does use an index. If you queries are joining tables across instances, however, then I'd be looking there for performance issues. Oracle doesn't join across instances really - it tends to just temporarily copy one table to a different instance. (Someone technical can explain this properly). Regards, Mark. Hopper, Wendy S To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] wendy.hopper@ cc: eds.com Subject: Query tuning with tablename alias Sent by: [EMAIL PROTECTED] om 21/11/2002 05:13 Please respond to ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: Query tuning with tablename alias
Title: RE: Query tuning with tablename alias but if you provide hints on such statements, you better be using aliases for hints . Aliases are used for readability ... you either use the aliases or user tablename.column but not both ... world is already confusing enough ... Raj __ Rajendra Jamadagni MIS, ESPN Inc. Rajendra dot Jamadagni at ESPN dot com Any opinion expressed here is personal and doesn't reflect that of ESPN Inc. QOTD: Any clod can have facts, but having an opinion is an art! *This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*1
RE: Query tuning with tablename alias
Knowing about how a hint works with aliases is what made me wonder about impacts to other areas. I have never seen it mentioned in any of the manuals I have read, and I just thought maybe someone else had experience with this. I am trying to figure out why the developer of these queries took the time to assign alias names to all these table names in their FROM clause, and then never used them elsewhere in the SELECT or WHERE portions. Maybe they were copying from a template... I realize there is a lot to be gained by moving the remote tables locally where possible. We are hoping to use local snapshots instead of going to remote instances. Thanks again! -Original Message- Sent: Wednesday, November 20, 2002 4:19 PM To: Multiple recipients of list ORACLE-L Wendy, I have never heard of alias' providing either a performance gain or reduction. One thing I haven't verified though is the impact on hints. It has been my observation that if a table has an alias then that alias must be used in the hint. For example: select /*+ index(user) */ * from ctcs_user u; Does not use an index, whereas: select /*+ index(u) */ * from ctcs_user u; Does use an index. If you queries are joining tables across instances, however, then I'd be looking there for performance issues. Oracle doesn't join across instances really - it tends to just temporarily copy one table to a different instance. (Someone technical can explain this properly). Regards, Mark. Hopper, Wendy S To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] wendy.hopper@ cc: eds.com Subject: Query tuning with tablename alias Sent by: [EMAIL PROTECTED] om 21/11/2002 05:13 Please respond to ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Hopper, Wendy S INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you
RE: Query tuning with tablename alias
Title: Message I do not think Oracle will run the sql below. Once you have an alias for a table, only that alias could be used as an alias (not the table name). Example: Oracle9i Enterprise Edition Release 9.2.0.2.0 - ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 9.2.0.2.0 - Production SQL desc dual;Name Null? Type- --DUMMY VARCHAR2(1) SQL select a.dummy from dual a; D-X SQL select dual.dummy from dual a;select dual.dummy from dual a *ERROR at line 1:ORA-00904: "DUAL"."DUMMY": invalid identifier SQL select dual.dummy from dual; D-X Waleed -Original Message-From: Hopper, Wendy S [mailto:[EMAIL PROTECTED]]Sent: Wednesday, November 20, 2002 1:13 PMTo: Multiple recipients of list ORACLE-LSubject: Query tuning with tablename alias Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an applicationthat generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE.SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Arethere any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred toby alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper
RE: Query tuning with tablename alias
Wendy - Could this SQL have been generated by a program? Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Wednesday, November 20, 2002 4:00 PM To: Multiple recipients of list ORACLE-L Knowing about how a hint works with aliases is what made me wonder about impacts to other areas. I have never seen it mentioned in any of the manuals I have read, and I just thought maybe someone else had experience with this. I am trying to figure out why the developer of these queries took the time to assign alias names to all these table names in their FROM clause, and then never used them elsewhere in the SELECT or WHERE portions. Maybe they were copying from a template... I realize there is a lot to be gained by moving the remote tables locally where possible. We are hoping to use local snapshots instead of going to remote instances. Thanks again! -Original Message- Sent: Wednesday, November 20, 2002 4:19 PM To: Multiple recipients of list ORACLE-L Wendy, I have never heard of alias' providing either a performance gain or reduction. One thing I haven't verified though is the impact on hints. It has been my observation that if a table has an alias then that alias must be used in the hint. For example: select /*+ index(user) */ * from ctcs_user u; Does not use an index, whereas: select /*+ index(u) */ * from ctcs_user u; Does use an index. If you queries are joining tables across instances, however, then I'd be looking there for performance issues. Oracle doesn't join across instances really - it tends to just temporarily copy one table to a different instance. (Someone technical can explain this properly). Regards, Mark. Hopper, Wendy S To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] wendy.hopper@ cc: eds.com Subject: Query tuning with tablename alias Sent by: [EMAIL PROTECTED] om 21/11/2002 05:13 Please respond to ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Hopper, Wendy S INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services
RE: Query tuning with tablename alias
I am thinking that it must have been, since the previous email correctly shows that it will not execute. I do not have access to the actual db and code yet, just paper copies of the queries that I was given to look over. Thanks to everyone for their feedback on this. Obviously this is not an issue. -Original Message- Sent: Wednesday, November 20, 2002 5:20 PM To: Multiple recipients of list ORACLE-L Wendy - Could this SQL have been generated by a program? Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Wednesday, November 20, 2002 4:00 PM To: Multiple recipients of list ORACLE-L Knowing about how a hint works with aliases is what made me wonder about impacts to other areas. I have never seen it mentioned in any of the manuals I have read, and I just thought maybe someone else had experience with this. I am trying to figure out why the developer of these queries took the time to assign alias names to all these table names in their FROM clause, and then never used them elsewhere in the SELECT or WHERE portions. Maybe they were copying from a template... I realize there is a lot to be gained by moving the remote tables locally where possible. We are hoping to use local snapshots instead of going to remote instances. Thanks again! -Original Message- Sent: Wednesday, November 20, 2002 4:19 PM To: Multiple recipients of list ORACLE-L Wendy, I have never heard of alias' providing either a performance gain or reduction. One thing I haven't verified though is the impact on hints. It has been my observation that if a table has an alias then that alias must be used in the hint. For example: select /*+ index(user) */ * from ctcs_user u; Does not use an index, whereas: select /*+ index(u) */ * from ctcs_user u; Does use an index. If you queries are joining tables across instances, however, then I'd be looking there for performance issues. Oracle doesn't join across instances really - it tends to just temporarily copy one table to a different instance. (Someone technical can explain this properly). Regards, Mark. Hopper, Wendy S To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] wendy.hopper@ cc: eds.com Subject: Query tuning with tablename alias Sent by: [EMAIL PROTECTED] om 21/11/2002 05:13 Please respond to ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want
RE: Query tuning with tablename alias
FWIW... Here is an interesting article by Jonathan Gennick: http://www.onlamp.com/lpt/a/2640 - Kirti -Original Message- Sent: Wednesday, November 20, 2002 4:44 PM To: Multiple recipients of list ORACLE-L I am thinking that it must have been, since the previous email correctly shows that it will not execute. I do not have access to the actual db and code yet, just paper copies of the queries that I was given to look over. Thanks to everyone for their feedback on this. Obviously this is not an issue. -Original Message- Sent: Wednesday, November 20, 2002 5:20 PM To: Multiple recipients of list ORACLE-L Wendy - Could this SQL have been generated by a program? Dennis Williams DBA Lifetouch, Inc. [EMAIL PROTECTED] -Original Message- Sent: Wednesday, November 20, 2002 4:00 PM To: Multiple recipients of list ORACLE-L Knowing about how a hint works with aliases is what made me wonder about impacts to other areas. I have never seen it mentioned in any of the manuals I have read, and I just thought maybe someone else had experience with this. I am trying to figure out why the developer of these queries took the time to assign alias names to all these table names in their FROM clause, and then never used them elsewhere in the SELECT or WHERE portions. Maybe they were copying from a template... I realize there is a lot to be gained by moving the remote tables locally where possible. We are hoping to use local snapshots instead of going to remote instances. Thanks again! -Original Message- Sent: Wednesday, November 20, 2002 4:19 PM To: Multiple recipients of list ORACLE-L Wendy, I have never heard of alias' providing either a performance gain or reduction. One thing I haven't verified though is the impact on hints. It has been my observation that if a table has an alias then that alias must be used in the hint. For example: select /*+ index(user) */ * from ctcs_user u; Does not use an index, whereas: select /*+ index(u) */ * from ctcs_user u; Does use an index. If you queries are joining tables across instances, however, then I'd be looking there for performance issues. Oracle doesn't join across instances really - it tends to just temporarily copy one table to a different instance. (Someone technical can explain this properly). Regards, Mark. Hopper, Wendy S To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] wendy.hopper@ cc: eds.com Subject: Query tuning with tablename alias Sent by: [EMAIL PROTECTED] om 21/11/2002 05:13 Please respond to ORACLE-L Hello list. I have recently been tasked with trying to optimize some slow performing queries (Oracle 8.1.7) for an application that generates reports in a data warehouse type environment. I have noticed in most of the queries that the table names have been aliased, but not used elsewhere in the query. IE. SELECT table1.column1, table1.column2, table2.column1 FROM table1 A, table2 B WHERE table1.key = table2.key; Are there any advantage/disadvantages to giving these tables aliases and not using them anywhere else? I am thinking that if the tables have been assigned alias names, they should be referred to by alias names, but I guess I have not seen anything documented on this officially. These queries join tables against remote tables in a different instance, if that makes a difference. Any insight on this would be great. Thanks. Wendy Hopper Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE