Answer the question
In order to leave comments, you need to log in
MariaDB (mySQL) - how to quickly (!) leave only unique options?
The question is more general than specific.
In response to the request, we get the answer: It is 1,2,5,8,1,2,2,4,3,5,7
necessary to get only unique (non-repeating) values - this: 1,2,5,8,4,3,7
Usually they use it for this SELECT DISTINCT
or GROUP BY
if the first one is impossible.
The problem is that the request without SELECT DISTINCT
is completed in about 4 minutes (the database is large - this is quite acceptable.) The
request with SELECT DISTINCT
- has already been executed for about half an hour, which is a very long time.
How to effectively solve such problems?
Answer the question
In order to leave comments, you need to log in
grids (display: grid and properties to describe grids) allow you to set this.
With the help of grids, at the level of the parent block, you can specify the standard width/height of the grid cell (both in fractions of the screen, and in pixels, as a percentage, alternating between different options), and already for a particular block, indicate the boundaries of its beginning/end vertically and horizontal lines, based on the grid described in the parent block (for example, specify that the first block goes from line 1 to line 3 in height, and in width - from line 1 to line 2, etc.). You can even specify in the description of the parent block which cells should be occupied by children, indicating their class (example here: https://developer.mozilla.org/en-US/docs/Web/CSS/C... )
Read more about grids at Russian here:https://developer.mozilla.org/en/docs/Web/CSS/CSS_...
It helped to use instead of DISTINCT
GROUP_BY
+ an index on the column on which it is executed.
Exploding - personal thanks!
No way.
To execute DISTINCT, sorting is needed - and this is a long time.
As an option - general optimization.
Look at the EXPLAIN PLAN to see what is going wrong with you, which is taking too long.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question