SunQuest
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 11th, 2003, 04:58 PM
mamtakansal mamtakansal is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 mamtakansal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Is there a way to improve the performance of this query..

Mr. Pabloj,

Thanks for your response. I am using Oracle 9i. I am not sure what do you mean by EXPLAIN plan?

Thanks!

I have the following query which runs fine, but if I remove the comments, it takes 3 minutes to run, as the table t_topics has about 4000 records. Is there any way to improve the performance of the query (after removing the comments):

SELECT distinct tm.canonical_mapping_topic_id,
tm.rule_id, tm.taxonomy_mapping_operand, tm.TAXONOMY_MAPPING_VERSION_ID,
ct.canonical_topic_name,
chv.CANONICAL_VERSION_ID, chv.CANONICAL_HIERARCHY_NAME, chv.CANONICAL_MAPPING_HIERARCHY_ID
-- t.topic_id, t.TOPIC_NAME, t.TOPIC_DESCRIPTION,
-- t.TOPIC_FACET, t.TOPIC_SOURCE,
FROM t_taxonomy_mapping tm, t_canonical_topics ct, t_canonical_hierarchy_version chv
--, t_topics t
WHERE tm.taxonomy_mapping_version_id = 439
AND ct.canonical_mapping_hierarchy_id = 41
AND chv.CANONICAL_MAPPING_HIERARCHY_ID = 41
AND tm.canonical_mapping_topic_id = ct.canonical_mapping_topic_id
-- AND t.PRESENT_TAXONOMY_TYPE_ID = 0
-- AND tm.TOPIC_ID = t.TOPIC_ID
ORDER BY
--t.TOPIC_ID,
tm.rule_id, tm.canonical_mapping_topic_id ASC;


Any help will be greatly appreciated!!

Thanks a lot in advance!

Regards,
Mamta.

Last edited by mamtakansal : July 12th, 2003 at 05:32 AM.

Reply With Quote
  #2  
Old July 12th, 2003, 01:01 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
Just staring at a query is not the way to optimize it!
Tell us on which database you are working, and, most important, show us an EXPLAIN plan for that query.

Reply With Quote
  #3  
Old July 12th, 2003, 12:27 PM
hedge hedge is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2002
Posts: 692 hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level)hedge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 21 h 22 m 10 sec
Reputation Power: 19
Also maybe a little more of the structure of your tables and what you are trying to accomplish.

4000 rows is nothing to a db, something has to be wrong for it to be taking that long.

Reply With Quote
  #4  
Old July 12th, 2003, 12:59 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259
Do you have indexed the tables?
EXPLAIN is a way of having the db show you how it's executing the query in order to find out problems.
To answer don't edit the first post, but post a reply instead

Reply With Quote
  #5  
Old July 12th, 2003, 01:51 PM
mamtakansal mamtakansal is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 mamtakansal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: Is there a way to improve the performance of this query..

Thanks to all of you for your kind responses.

Brief summary of what I am trying to accomplish:

I have two different kinds of topic hierarchies, presentation topics (table t_topics) and canonical topics (table t_canonical_topics). There are mapping rules defined between these topics in
the table t_taxonomy_mapping. t_canonical_hierarchy_version has the canonical_mapping_hierarchy_id,
which tells the version number of canonical topics hierarchy. I need to pick the taxonomy mapping rules,
the corresponding canonical_topic_id, canonical_topic_name, topic_id and some other information on presentation topic from the t_topics table, for a given canonical_mapping_hierarchy_id and taxonomy_mapping_version_id (there are different mapping versions in the t_taxonomy_mapping table).

t_taxonomy_mapping is the child table of t_topics. topic_id is the PK in t_topics and is FK in t_taxonomy_mapping.

t_taxonomy_mapping (canonical_mapping_topic_id FK) is also the child table of t_canonical_topics (canonical_mapping_topic_id PK, canonical_mapping_hierarchy_id FK) which is the
child table of t_canonical_hierarchy_version (canonical_mapping_hierarchy_id PK)


The indexes defined are as follows:

CREATE INDEX IX_TOPIC_NAME ON T_TOPICS
(TOPIC_NAME)

CREATE UNIQUE INDEX PK_TOPICS ON T_TOPICS
(TOPIC_ID)

CREATE INDEX TYPE_IDX ON T_TOPICS
(PRESENT_TAXONOMY_TYPE_ID)

CREATE UNIQUE INDEX PK_TAXONOMY_MAPPING ON T_TAXONOMY_MAPPING
(TAXONOMY_MAPPING_ID)

CREATE UNIQUE INDEX UNIQUEIDX ON T_TAXONOMY_MAPPING
(CANONICAL_MAPPING_TOPIC_ID, TOPIC_ID, TAXONOMY_MAPPING_VERSION_ID, RULE_ID)

CREATE UNIQUE INDEX IDX_CANONICAL_UNIQUE ON T_CANONICAL_TOPICS
(CANONICAL_TOPIC_ID, CANONICAL_MAPPING_HIERARCHY_ID)

CREATE UNIQUE INDEX PK_CANONICAL_TOPICS ON T_CANONICAL_TOPICS
(CANONICAL_MAPPING_TOPIC_ID)

CREATE UNIQUE INDEX PK_CANONICAL_HIERARCHY_VERSION ON T_CANONICAL_HIERARCHY_VERSION
(CANONICAL_MAPPING_HIERARCHY_ID)


I hope, I am clear enough in explaining the problem. Please let me know if I need to explain anything further.

Thanks again for your help!

Sincerely,
Mamta.




Also maybe a little more of the structure of your tables and what you are trying to accomplish.

4000 rows is nothing to a db, something has to be wrong for it to be taking that long.


Do you have indexed the tables?
EXPLAIN is a way of having the db show you how it's executing the query in order to find out problems.
To answer don't edit the first post, but post a reply instead

Reply With Quote
  #6  
Old July 12th, 2003, 06:29 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,686 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 5 Days 16 h 27 m 51 sec
Reputation Power: 259

Reply With Quote
  #7  
Old July 14th, 2003, 08:16 AM
mamtakansal mamtakansal is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 10 mamtakansal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: Is there a way to improve the performance of this query..

Mr. Pabloj,

Thanks a lot for the link for EXPAIN plan! It's very helpful.

Sincerely,
Mamta Kansal.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Is there a way to improve the performance of this query..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway