sql order by - MYSQL has orderBy on count(*) some impact on perfomance? -
i have simple query count number of records plain query inner joins , criterions.
something this.
select count(*) ...... .... order .........at 4 fields.
my question order asc or desc @ 4 fields has impact on performance? or ignore or optimized engine.
sorry if question plain or simple best regards.
first, should note query, written, return 1 row. have aggregation function no group by
. in situation, order by
no-op (i don't know if mysql goes through motions 1 row or not).
in general, performance impact of order by
depends on number of rows, not number of keys.
i can think of 2 occasions when order by
has minimal impact on performance:
- an index can used ordering.
- it follows
group by
, uses aggregation keys (this true in mysql sortgroup by
).
and, of course, order by
on few rows (such 4 rows) pretty negligible performance-wise.
the impact, though, has less size of keys number of rows , overall size of rows. multiple joins , where
clause, unlikely (but not impossible) query use index order by
.
Comments
Post a Comment