Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0.0, 5.5.28, 5.3.11
-
None
-
CentOS 64bit, Ubuntu 11.10 64bit
Description
I use the built-in functions "to_days(now())" all the time in my application and queries. To save typing, I shortened this in a user-defined function "tdn()" like this:
CREATE FUNCTION tdn() RETURNS int(7) DETERMINISTIC RETURN to_days(now());
When I issue an UPDATE or DELETE statement of a large (300 million rows), fully indexed table like this:
update <table> set <field>=<value> where daynum=to_days(now()) <plus optional extra criteria>
or
delete from <table> where daynum=to_days(now()) <plus optional extra criteria>
The update uses the index on the "daynum" field to properly update or delete the proper records.
but if I do the same thing using my UDF:
update <table> set <field>=<value> where daynum=tdn() <plus optional extra criteria>
or
delete from <table> where daynum=tdn() <plus optional extra criteria>
the query does a full table scan.
The exact same UPDATE and DELETE queries running on MySQL 5.5.8 both properly use the index using both methods.
All equivalent SELECT queries also use the index as expected on both platforms.
The problem only occurs when doing and UPDATE or DELETE and my UDF is in the where clause of an indexed field. But only in MaraiDB and not in MySQL.
Is there a workaround for this, or is this an optimizer bug?
I'm actually running version MariaDB 5.5.27.
Attachments
Activity
Field | Original Value | New Value |
---|---|---|
Priority | Critical [ 2 ] | Major [ 3 ] |
Fix Version/s | 10.0.1 [ 11400 ] | |
Fix Version/s | 5.5.29 [ 12102 ] |
Affects Version/s | 5.3.11 [ 11700 ] | |
Affects Version/s | 10.0.0 [ 10000 ] |
Assignee | Sergei Petrunia [ psergey ] |
Environment | CentOS 64bit | CentOS 64bit, Ubuntu 11.10 64bit |
Fix Version/s | 5.3.12 [ 12000 ] |
Labels | optimizer udf update | optimizer update |
Labels | optimizer update | optimizer |
Summary | Optimizer difference between MySQL and MariaDB with user defined functions in WHERE clause of UPDATE or DELETE statements | Optimizer difference between MySQL and MariaDB with stored functions in WHERE clause of UPDATE or DELETE statements |
Assignee | Sergei Petrunia [ psergey ] | Timour Katchaounov [ timour ] |
Status | Open [ 1 ] | In Progress [ 3 ] |
Assignee | Timour Katchaounov [ timour ] | Oleksandr Byelkin [ sanja ] |
Assignee | Oleksandr Byelkin [ sanja ] | Timour Katchaounov [ timour ] |
Status | In Progress [ 3 ] | Open [ 1 ] |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | defaullt [ 25427 ] | MariaDB v2 [ 46374 ] |
Workflow | MariaDB v2 [ 46374 ] | MariaDB v3 [ 64380 ] |
Workflow | MariaDB v3 [ 64380 ] | MariaDB v4 [ 146233 ] |