Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Select MAX

Select MAX

2007-06-25       - By Daniel Castro

 Back
Hi,

I have the following query :

SELECT PAC.PAC_PRONT,PAC.PAC_NOME, PC.CID_NOME CID_NOME_PC, PAC.pac_dreg,
OSM.OSM_CNV, CNV.CNV_NOME,
MAX ( FIXED ( DATEDIFF ( PAC.PAC_NASC, timestamp ) / 365, 5 ) )
FROM PAC, SMM, OSM, CNV, STR B, CID PC WHERE ( SMM.SMM_SFAT <> 'C' )
AND ( OSM.OSM_SERIE = SMM.SMM_OSM_SERIE )
AND ( OSM.OSM_NUM = SMM.SMM_OSM )
AND ( OSM.OSM_CNV = CNV.CNV_COD )
AND ( B.STR_COD = OSM.OSM_STR )
AND ( OSM.OSM_PAC = PAC.PAC_REG )
AND ( PAC.PAC_DIAG_CID = PC.CID_COD (+) )
AND ( ( PAC_DREG >= '1979-01-01 00:00:00' AND PAC_DREG < '2007-01-01
00:00:00' )
AND ( OSM.OSM_DTHR >= '2007-01-01 00:00:00' AND OSM.OSM_DTHR < '2007-02-01
00:00:00' ) )
AND ( B.STR_STR_COD = '1' )
GROUP BY PAC.PAC_PRONT, PAC.PAC_NOME, PC.CID_NOME, PAC.pac_dreg, OSM.OSM_CNV,
CNV.CNV_NOME


with the following explain:


DBA PAC TABLE SCAN 8664

DBA SMM TABLE SCAN 5585

DBA OSM JOIN VIA MULTIPLE KEY COLUMNS 1355

OSM_SERIE (USED KEY COLUMN)

OSM_NUM (USED KEY COLUMN)

DBA CNV CNV_COD JOIN VIA KEY COLUMN 35

B STR_COD JOIN VIA KEY COLUMN 1

PC CID_COD JOIN VIA KEY RANGE 439

INTERNAL TEMPORARY RESULT TABLE SCAN 500

DBA RESULT IS COPIED , COSTVALUE IS 754813588


I tried to create a index with PAC_NASC, desc, to avoid the SCAN but it did
not worked.

Can you give me any help?

This query is crashing SAP DB.


Best regards,





--
Daniel Castro - ?????
MSN: danielti@(protected)
Skype: danielti2005
ICQ : 316727989
Jabber: danielti
Linux User: 387864
AOL User: Danielti2005
Sola Scriptura, Sola Gratia, Sola Fide, Solus Christus, Soli Deo Gloria