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()
 
UDF in WHERE clause causes an odd execution plan

UDF in WHERE clause causes an odd execution plan

2007-05-18       - By Vlad Arkhipov

 Back
Reply:     1     2  

CREATE TABLE GIS2.SERVICES (
   ID INTEGER NOT NULL DEFAULT SERIAL(1) PRIMARY KEY,
   CODE VARCHAR(10) NOT NULL UNIQUE
)

CREATE TABLE GIS2.SERVICE_DATA (
   ID INTEGER NOT NULL DEFAULT SERIAL(1) PRIMARY KEY
)

CREATE FUNCTION GIS2.GETSERVICEID (
   RESID CHAR(10))
RETURNS INTEGER
AS
   VAR ID INTEGER;

   TRY
       SELECT ID INTO :ID FROM GIS2.SERVICES WHERE CODE = :RESID;
   CATCH
       IF $rc <> 100 THEN STOP($rc, 'unexpected error')
       ELSE RETURN NULL;

   RETURN ID;

EXPLAIN
SELECT ID
FROM GIS2.SERVICE_DATA
WHERE ID = 1

OWNER     TABLENAME      COLUMN_OR_INDEX    
STRATEGY                                PAGECOUNT  
-- -----  -- ---- -----  -- ---- ---- -----  
-- ---- ---- ---- ---- ---- ---- -----  -- ---- ----
GIS2      SERVICE_DATA                       EQUAL CONDITION FOR
KEY                        542  
                         ID                       (USED KEY
COLUMN)                              
          JDBC_CURSOR_4                         RESULT IS NOT COPIED ,
COSTVALUE IS           1  

EXPLAIN
SELECT ID
FROM GIS2.SERVICE_DATA
WHERE ID = GIS2.GETSERVICEID('12345')

OWNER     TABLENAME      COLUMN_OR_INDEX    
STRATEGY                                PAGECOUNT  
-- -----  -- ---- -----  -- ---- ---- -----  
-- ---- ---- ---- ---- ---- ---- -----  -- ---- ----
GIS2      SERVICE_DATA                       TABLE
SCAN                                      35  
          JDBC_CURSOR_2                         RESULT IS NOT COPIED ,
COSTVALUE IS          35  

Tested on MaxDB 7.6.00.16 - 016-123-109-428.

--
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/maxdb?unsub=mysql@(protected)