Subject Re: Question regarding index
Author firebirdsql
So the order of the columns matter in the where clause filter. Doesn't the optimizer automatically rearrange the filter columns etc?

--- In firebird-support@yahoogroups.com, W O <sistemas2000profesional@...> wrote:
>
> Yes, you are right, when you define a primary key an index is created.
>
> If you does the query in the same order, the primary's key index is used. By
> example:
> - username, title ---> uses the primary's key index
> - title, start_date ---> don't use the primarys key index, because it
> has not a "username" column
> - title, start_date, username ---> don't use the primary's key index
> because the column "username" is not the first column.
>
> Greetings.
>
> Walter.
>
>
>
> On Sun, Sep 11, 2011 at 2:17 PM, firebirdsql <firebirdsql@...> wrote:
>
> > **
> >
> >
> > If I a tables primary key is (username, title, start_date)...I'm guessing
> > it
> > will create an index on (username, title, start_date).
> >
> > If I'm querying by username, start_date, will it still use the index OR do
> > I
> > need to add an extra index for username, start_date)?
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>