SQL Server: How can table scans be so expensive on a tiny table?

I look at the execution plan from an unpleasant request.

I see that 45% of the plan is busy doing a table scan on a table with seven (7) rows of data.

I'm going to put a clustered index to cover the columns in my query on a seven-row table, and it feels ... wrong. How can this part of my query cover so much plan that the table is so tiny?

I read here , and he feels that it might just be due to non-contiguous data - there are no indexes at all in the table in question. In general, although our database is large (7 GB) and busy.

I would like to know what others think - thanks!

EDIT:

The request is executed very often and is involved in a dead end (and selected as a victim). Now it takes from 300 ms to 500 ms to start, but it will take longer when the database is more busy.

Inquiry:

select l.team1Score, l.team2Score, ls.team1ExternalID, ls.team2ExternalID, et.eventCategoryID, e.eventID, ls.statusCode 
from livescoretracking l(nolock) 
inner join liveScores ls (nolock) on l.liveScoreID = ls.liveScoreID 
inner join db1.dbo.events e on e.gameid = ls.gameid 
inner join db1.dbo.eventtype et (nolock) on e.eventTypeID = et.eventTypeID 
inner join eventCategoryPayTypeMappings ecb (nolock) on ( et.eventCategoryID = ecb.eventCategoryID and e.payTypeID = ecb.payTypeID and ecb.mainEvent = 1 ) 
where ls.gameID = 286711 order by l.dateinserted

Problem table - eventCategoryPayTypeMappings table - thanks!

+3
source share
6 answers

Interest cost is meaningless, not knowing the total value in real terms. for example, if a query takes 1 ms to complete 45% of the cost of scanning a table, it’s 0.45 milliseconds that you should not try to optimize if the query takes 10 seconds, and then the 45% cost is significant and worth optimizing.

+1

. , , . , , ?

+1

, . .

, , . ( SQL Server.)

.

+1

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

+1

, . 45% , , 10 . , , , .

, , , , , . , 7 .

0

. , , , .

, , "" ( , ).

0

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


All Articles