How to count with SQL?

Learn SQL for work. Faced with very large tables, respectively, and it is considered long or not considered at all. How to correctly approach the write a query to increase performance?

For example:

SELECT UserId, Name, Text
FROM table
WHERE UserId > 10000


P. S I'm a noob, be kind
June 14th 19 at 20:52
4 answers
June 14th 19 at 20:54
Solution
In this case, to make an index on the UserId field - fly will be selected.
Thank you - Triston_Jerde commented on June 14th 19 at 20:57
June 14th 19 at 20:56
Read about indexes
Thank you - Triston_Jerde commented on June 14th 19 at 20:59
June 14th 19 at 20:58
You can add names or texts?

Apparently so:
SELECT COUNT(*)
FROM table
WHERE UserId > 10000

it is possible still so:
SELECT SUM(UserId)
FROM table
WHERE UserId > 10000

or even so:
SELECT AVG(LEN(Text))
FROM table
WHERE UserId > 10000
I don't fold, and I did not understand you :) - Triston_Jerde commented on June 14th 19 at 21:01
You wrote "it is" - I thought you believe the statistics.
Apparently you meant "read". Carefully write questions. - Triston_Jerde commented on June 14th 19 at 21:04
well, thank you. - Triston_Jerde commented on June 14th 19 at 21:07
June 14th 19 at 21:00
1. To solve - and why the heck is generally necessary. Large samples are necessary to nobody. People even view can't. The request must be such that the answer was compact. And then you first select a long time, then the communication channels transmit for a long time, then people are all not looking......

2. Index add. You have already said.
1. Well, apparently it is necessary :)
2. I noticed. - Triston_Jerde commented on June 14th 19 at 21:03

Find more questions by tags SQLOptimization of SQL-queries