Thread: What is the fastest null WHERE

What is the fastest null WHERE

From
"Mindaugas Riauba"
Date:
  Hello,

  While writing web application I found that it would
be very nice for me to have "null" WHERE clause. Like
WHERE 1=1. Then it is easy to concat additional
conditions just using $query . " AND col=false" syntax.

  But which of the possible "null" clauses is the fastest
one?

  Thanks,

  Mindaugas


Re: What is the fastest null WHERE

From
Shridhar Daithankar
Date:
Mindaugas Riauba wrote:

>   Hello,
>
>   While writing web application I found that it would
> be very nice for me to have "null" WHERE clause. Like
> WHERE 1=1. Then it is easy to concat additional
> conditions just using $query . " AND col=false" syntax.
>
>   But which of the possible "null" clauses is the fastest
> one?

Rather than this approach, keep a flag which tells you whether or not it is
first where condition. If it is not first where condition, add a 'and'. That
would be simple, isn't it?

  Shridhar


Re: What is the fastest null WHERE

From
Richard Huxton
Date:
On Wednesday 01 October 2003 13:11, Mindaugas Riauba wrote:
>   Hello,
>
>   While writing web application I found that it would
> be very nice for me to have "null" WHERE clause. Like
> WHERE 1=1. Then it is easy to concat additional
> conditions just using $query . " AND col=false" syntax.
>
>   But which of the possible "null" clauses is the fastest
> one?

I suspect WHERE true, but is it really necessary.

Most languages will have a join() operator that lets you do something like:

$where_cond = join(' AND ', @list_of_tests)



--
  Richard Huxton
  Archonet Ltd

Re: What is the fastest null WHERE

From
Rod Taylor
Date:
On Wed, 2003-10-01 at 08:11, Mindaugas Riauba wrote:
> While writing web application I found that it would
> be very nice for me to have "null" WHERE clause. Like
> WHERE 1=1. Then it is easy to concat additional
> conditions just using $query . " AND col=false" syntax.
>
>   But which of the possible "null" clauses is the fastest
> one?

WHERE true AND ....



Attachment

Re: What is the fastest null WHERE

From
"Mindaugas Riauba"
Date:
> >   While writing web application I found that it would
> > be very nice for me to have "null" WHERE clause. Like
> > WHERE 1=1. Then it is easy to concat additional
> > conditions just using $query . " AND col=false" syntax.
> >
> >   But which of the possible "null" clauses is the fastest
> > one?
>
> I suspect WHERE true, but is it really necessary.

  Thanks. I'll use "WHERE true" for now. And of course it is
not necessary it just simplifies code a bit.

> Most languages will have a join() operator that lets you do something
like:
>
> $where_cond = join(' AND ', @list_of_tests)

  That's not the case. Test may or may not be performed based on
web form values.

  Mindaugas