Results 1 to 4 of 4
Thread: What does LIMIT do?
Jun 4, 2007, 10:16 #1
What does LIMIT do?
Hi in MySQL, when I do LIMIT x, how does the database work?
1) Does it pull everything relevant, then only takes the x starting from 0 or.
2) Does it only pull the first x amount out and stops?
Jun 4, 2007, 10:45 #2
- Join Date
- Aug 2000
- Philadephia, PA
- 1 Post(s)
- 0 Thread(s)
#2 whenever possible.Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
Jun 4, 2007, 11:01 #3
In the case of something like, ORDER BY column LIMIT 5, would it do #1. And if so is there a more efficient method of doing such?
And if there's no column and it's just like SELECT * FROM tbl WHERE x=1 LIMIT 5, it would do #2?
Jun 4, 2007, 17:58 #4
- Join Date
- Jul 2002
- Toronto, Canada
- 49 Post(s)
- 1 Thread(s)
it would use #2 if there is an ORDER BY and the order by column has an index
i've always wondered why people would want to use LIMIT without ORDER BY -- it's not like you're going to get a random selection, you're not, you will probably get the earliest rows, but this isn't guaranteed