Is 20 SQL Queries Per Page Queries Really Many?

I read Jeff Atwood 's blog on Here's WordPress, a Processor Destroyer, and I saw that many people viewed 20 SQL queries per page a lot. What is the average number of page requests currently for a highly dynamic auto-suggest page, auto-refresh of data, custom pages, and a kitchen sink?

For a simple example, Amazon.com is practically setting up my homepage with what they think I will buy. For me it doesn't look like it uses 5 or fewer requests for the first page.

I'm still a newbie with databases, so please tell me if I am missing something obvious.

+25
source share
9 answers

You can usually transfer all data in two or three large queries instead of 20 small ones. Minimizing the number of queries is just as important as, if not the most important, writing optimal queries to maximize performance.

Of course, you should always analyze query plans and strive for optimal queries, to be small or large.

The fact is that poorly designed web pages fulfill many requests, one for each small small task that can be easily grouped into one request.

, stackoverflow , , , , . 20 . , , .

, , , - .

+24

.

, , . . .. , , ( , ).

, memcached - . ( Wordpress), , .

. N + 1, , . , , .

+12

: - - - ,

, , 20 . , Amazon, .

- .

, , - .

+5

, 5 ...

- , , , QUERIES.

20 , ( ) 20 , 20 .

, , , .....

+4

20 , , , .

, , , - .

, , 5 6 , , - SQL, , 200 . . (700k viewstate , ...) , - .

, , , , 5 , , - digg.

5 , .

+1

, , Ajax, , , 3 . :

  • ( );
  • ( 1: 0-1 );
  • (1: M 2).

; , , .

+1

, , 5-7, .

, , , , , 20.

, , , , , 15 ...

0

. , . , . eachother , , , . , , , , . 100 - 300 . , 20 , 4-6 .

LINQ, , , 20 . , , .

, Jeff , , , TCP. ( Hanselminutes .)

LINQ . , , 6 . , , .

0

, , .

SQL-, 20 -, - , 60 .

, (, Oracle MySql), 20 , , . , , , .

, , . , .

An example from Vinko may be true for small, 1 week development projects, but if you ask about Amazon, they don’t use your common PHP / MySQL development package; behind the front door lies a complex system of distributed computing and data mining algorithms. If you are a beginner, you should not take such big brothers for reference ...

0
source

Source: https://habr.com/ru/post/1709161/


All Articles