S
S
speed82014-09-21 16:24:39
MySQL
speed8, 2014-09-21 16:24:39

How to make a block diagram?

It is necessary to draw up a block diagram that checks the possibility of constructing a triangle on three sides. The brain has already turned.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
shagguboy, 2016-09-23
@shagguboy

>We need a composite age_gender index because MySQL only uses 1 index >a query
in 5.7 has a merge of indexes.
queries can use the first fields of compound indexes.
SELECT * FROM `users` WHERE `age` > 20 AND `gender` = 'male' ORDER BY `name`
SELECT * FROM `users` WHERE `age` > 20 AND `gender` = 'male' ORDER BY `rating`
these two queries can use the index (age, gender, rating)
the second query can use the index (age, gender) but only for filtering sorting will be on disk (using filesort) uncritical for small samples.

M
Maxim Fedorov, 2016-09-20
@qonand

you need to understand that indexes also eat resources, so you should not abuse them. Make a lot of indexes and as a result, for example, get a very slow write to the database. Therefore, it is not necessary to cover all queries with indexes during the development process. It’s better to turn on the slow query log in MySQL and, based on the data from it, determine how to optimize this or that query - put an index or do something else

A
Anton Fedoryan, 2014-09-24
@speed8

What exactly is the problem?
A triangle exists if the sum of the legs (two smaller sides) is not equal to the hypotenuse (larger side), but rather more than it (and necessarily more).
The algorithm is as follows:
1) Find the largest side
2) Compare with the sum of the other two
3) If equal or less than the hypotenuse, it is impossible to build such a triangle.
Or is it a matter of what blocks to use to build the circuit?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question