문제

Say I have a table X with 100 records in it and that running a select * from X takes 100 seconds.

How long should I expect the query select top 10 * from X to take?

I'd expect that the relationship is more or less linear so 10 seconds. Is this correct, or is the relationship non-linear in some way?

도움이 되었습니까?

해결책

Your performance cost is in two different areas:

  • How long it takes to perform the query
  • How long it takes to return the results

Often, a query will be fast, but returning results will be slow, since it's I/O-bound. If this is the case, then you will see an approximately linear speedup by returning fewer results.

However, if the query itself is complicated, things are different. If it's not just select * from X, but select * from X where [complicated-expression], then results may vary widely between database implementations. In that case, your performance might be dominated by query complexity, in which case you won't see as much benefit by merely returning fewer results.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top