|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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. ![]() |
|
#2
|
||||
|
||||
|
Try creating an ascending index on the mp.Codigo column and see if there is any improvement !!
|
|
#3
|
|||
|
|||
|
Quote:
I have an index on this field. And i try other outer joins queries and in all i have bad performance. |
|
#4
|
||||
|
||||
|
Quote:
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 ? |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
firebird left outer joins
Same problem here left outer joins fail dunno why..Does firebird not support left outer joins?
SQLserver does so well |
|
#7
|
||||
|
||||
|
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
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Last edited by pabloj : March 24th, 2008 at 06:00 AM. |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Left Outer Join bad performance |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|