4 messages in com.mysql.lists.mysqlRe: 2 questions 1) Limit x,y 2) selec...
FromSent OnAttachments
Patric de Waha09 Sep 1999 05:12 
sin...@cytanet.com.cy09 Sep 1999 05:26 
Martin Ramsch09 Sep 1999 11:17 
Michael Widenius14 Sep 1999 04:56 
Subject:Re: 2 questions 1) Limit x,y 2) select *,somefunction(x)
From:sin...@cytanet.com.cy (sin@cytanet.com.cy)
Date:09/09/1999 05:26:12 AM
List:com.mysql.lists.mysql

Patric de Waha writes:

Hi, Ok I 've two questions :)

1) I've to limit the results to a specific range (It's something like a spider search, where the user can select the page (and range) to display). Ok for that I use the limit expression:

SELECT * from tblads where x=y limit 10,10;

Well this displays the ads from 10 to 20

Ok but now I need to know what was the row count if wouldn't limit the result (It's normal that the user wants to know how many ads his query returned).

If possible I don't want to requery because the query can be very complicated and slow.

ok :)

2) When I do a SELECT *,some_slowfunction(x) from tblads join xx on w=y where n=s;

:)

Now what I want to know is: Is the some_slowfunction(x) function calculated before the where applies to the table?!

Or is the some_slowfunction(x) calculated on the resulting table?!

Last would be a lot faster of course, that's what I need to know :)

I hope someone can help me out :)

btw: I use php

Thanks in advance

Hi!

1) yes, you will get rows from 11 to 20. And total number of rows will have to be asked from client, which again depends on the version used.

2) That function is calculated on the column from the chosen row. And that row is filtered through where statement. Check with EXPLAIN whether MySQL uses indices for the purpose.

Sinisa