A
A
Andrey2017-09-09 06:11:54
css
Andrey, 2017-09-09 06:11:54

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 DISTINCTor GROUP BYif the first one is impossible.
The problem is that the request without SELECT DISTINCTis 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

5 answer(s)
U
UndineS, 2019-05-21
@kamisarlapsha

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_...

A
Alfieros, 2019-05-21
@mrsexy

Write your own solution and you will be corrected/directed.

A
Andrey, 2017-09-09
@andrshpa

It helped to use instead of DISTINCT
GROUP_BY+ an index on the column on which it is executed.
Exploding - personal thanks!

B
buzina_v_ogorode, 2017-09-09
@buzina_v_ogorode

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.

O
oh, 2017-09-09
well @AnneSmith

sort in the database, remove duplicates by code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question