SunQuest
           Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old January 31st, 2005, 09:37 PM
diegod diegod is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 9 diegod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 26 sec
Reputation Power: 0
Left Outer Join bad performance

I`am having very bad performance using outer joins sentences in my quieries.
I read in the internet that FB 1.5 have problems with "outer joins". Is that True ?

if I run this:

Select mp.*, phc.*
From Maestro_Pacientes mp
Left Outer join Paciente_hc phc On mp.Codigo = phc.Paciente
Where mp.Codigo >= 1

the execution plan is this:
Plan
PLAN JOIN (MP INDEX (RDB$PRIMARY58),PHC INDEX (PK_PACIENTE_HC))
Adapted Plan
PLAN JOIN (MP INDEX (INTEG_526),PHC INDEX (PK_PACIENTE_HC))

------ Performance info ------
Prepare time = 0ms
Execute time = 32ms
Avg fetch time = 2.67 ms
Current memory = 1,879,652
Max memory = 2,110,108
Memory buffers = 2,048
Reads from disk to cache = 586
Writes from cache to disk = 0
Fetches from cache = 712

It runs ver fast....
But I need the recordset order By "Codigo"
like thist:

Select mp.*, phc.*
From Maestro_Pacientes mp
Left Outer join Paciente_hc phc On mp.Codigo = phc.Paciente
Where mp.Codigo >= 1 order By mp.Codigo

and the execution plan is this:
Plan
PLAN SORT (JOIN (MP INDEX (RDB$PRIMARY58),PHC INDEX (PK_PACIENTE_HC)))

Adapted Plan
PLAN SORT (JOIN (MP INDEX (INTEG_526),PHC INDEX (PK_PACIENTE_HC)))

------ Performance info ------
Prepare time = 0ms
Execute time = 8s 266ms
Avg fetch time = 688.83 ms
Current memory = 1,883,264
Max memory = 2,110,108
Memory buffers = 2,048
Reads from disk to cache = 15,661
Writes from cache to disk = 0
Fetches from cache = 1,956,941

It takes 8 seconds. too much compare to the other plan.
I see that Firebird make a sort of all the tables involved in the plan.
In table (Maestros_Pacientes) I have 335.000 records. And in table (Paciente_Hc) I have 140.000 records.
The performance Analisis in the second plan says that the indexed reads in
each table are equal to the number of record in each one.
Wath can i do to improve that ?

Sorry for my english ! I speak in spanish.

Reply With Quote
  #2  
Old February 1st, 2005, 10:20 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 4
Send a message via Yahoo to SilverDB
Try creating an ascending index on the mp.Codigo column and see if there is any improvement !!

Reply With Quote
  #3  
Old February 1st, 2005, 11:11 AM
diegod diegod is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 9 diegod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 26 sec
Reputation Power: 0
Quote:
Originally Posted by SilverDB
Try creating an ascending index on the mp.Codigo column and see if there is any improvement !!


I have an index on this field.
And i try other outer joins queries and in all i have bad performance.

Reply With Quote
  #4  
Old February 2nd, 2005, 07:00 AM
SilverDB's Avatar
SilverDB SilverDB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Romania
Posts: 173 SilverDB User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 45 m 53 sec
Reputation Power: 4
Send a message via Yahoo to SilverDB
Quote:
Originally Posted by diegod
1st ------ Performance info ------
Reads from disk to cache = 586
Writes from cache to disk = 0
Fetches from cache = 712

2nd ------ Performance info ------
Reads from disk to cache = 15,661
Writes from cache to disk = 0
Fetches from cache = 1,956,941

It takes 8 seconds. too much compare to the other plan.


Taking a fast look at this I can see a big difference between the 1st and the 2nd test.
I don't think that there is anything else you can do to improve the response time.
What is your Firebird server configuration ? Processor, memory etc ?

Reply With Quote
  #5  
Old February 2nd, 2005, 07:35 PM
diegod diegod is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 9 diegod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 26 sec
Reputation Power: 0
bad performance

I have read that Left outer join creates a Cartesian product , so the server need some time to sort all records.
But in MSSQL the same Database and the same query works fine.
I Carlos Valderrama firebird Web I have read that the is a problem of the FB version and they are working on that.
Until the resolve this problem I will not use leoft Outer joins queries.

Reply With Quote
  #6  
Old March 23rd, 2008, 03:27 AM
molochgoa molochgoa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Location: russia
Posts: 4 molochgoa User rank is Private First Class (20 - 50 Reputation Level)molochgoa User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 h 16 m 33 sec
Reputation Power: 0
firebird left outer joins

Same problem here left outer joins fail dunno why..Does firebird not support left outer joins?
SQLserver does so well

Reply With Quote
  #7  
Old March 23rd, 2008, 03:44 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,707 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 6 Days 3 h 1 m 35 sec
Reputation Power: 259
molochgoa,
please don't dig threads, if you have a problem with a query post it with detailed explaination (actual query, table structure, error message, explain plan, whatever ...)
Left outer joins work and well, no carthesian products unless introduced by the one who writes the query

Here is the follow up thread with molochgoa's question

Last edited by pabloj : March 24th, 2008 at 06:00 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Left Outer Join bad performance


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 4 hosted by Hostway