MySQL Forums
Forum List  »  Optimizer & Parser

Re: Eternal SELECT queries
Posted by: Felix Geerinckx
Date: November 15, 2005 09:20AM

Aniceto Perez wrote:

> I have two tables: A and B. Table A has one field named CODI, char(5), and 4M records.
> Table B has two fields named COD1, char(2), and COD2, char(3), and 100K records.
> The CODI field has an index, also there is an index for both COD1 and COD2.
>
> I am testing this query:
>
> SELECT AVG(A.pre) FROM A INNER JOIN B ON A.CODI=B.COD1+B.COD2 WHERE B.F=2;

1) You are "adding" two character columns. If you want to concat them, use CONCAT(B.COD1, B.COD2)

2) You need an index on B.F

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Views
Written By
Posted
3082
November 15, 2005 03:31AM
Re: Eternal SELECT queries
2102
November 15, 2005 09:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.