STATISTICS IO: Scan Count vs Logical reads
Hello
I'm doing som performance research, I have a index with following priority: ClientId, Active, ProductId. Active is a bit field telling whether the Product is active or not, it can be inactive products than active, but always at least one active product.
When I'm executing
SELECT * FROM [table] WHERE ClientId = [id] AND ProductId IN (1,2,3,5,7,9,20)
I'm getting following result: Scan count 1, logical reads 490
When I'm leading SQL Server to the right paths by including the to possible values in Active by executing the following SQL:
SELECT * FROM [table] WHERE ClientId = [id] AND ProductId IN (1,2,3,5,7,9,20) AND Active IN (0,1)
I'm getting following results: Scan count 14, logical reads 123
With this information, which version would you say is fastest and why?
When I was running this query 1000 times with different ClientId I got a average time of 172 ms for the first query, and 155 ms for the second one. I have been told that scan count is very expensive... out of this example it seems that the cost of 1 scan count is like 20 logical reads?
When I was running this query 1000 times with different ClientId I got a average time of 172 ms for the first query, and 155 ms for the second one. I have been told that scan count is very expensive... out of this example
it seems that the cost of 1 scan count is like 20 logical reads?
Typically the pages are forced out of buffer (DBCC DROPCLEANBUFFERS) when doing such a measurement:
http://www.sqlusa.com/bestpractices2005/executioninms/
BOL: "Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server."
LINK: http://technet.microsoft.com/en-us/library/ms187762.aspx
Kalman Toth Database & OLAP Architect
SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
Similar Messages
-
I have two versions of a query.
1. Scan count 136, logical reads 2776907,CPU time = 230848 ms, elapsed time = 55753 ms.
2. Scan count 0, logical reads 89225788, CPU time = 437696 ms, elapsed time = 46195 ms.
The only difference I can see is 2 query it taking lesser of 10 minutes. Which is good here? Both Execution plan has lots of hash joins.
SrinivasanHi Srinivasan,
Scan counts should be as low as possible. As for Logical Reads, you want them to be as high as possible and more than physical
reads is preferred (read from cache as opposed to drive).
Scan count: Number
of index or table scans performed.
logical reads: Number of pages read from the data cache.
For more info you can refer the msdn link => http://msdn.microsoft.com/en-us/library/ms184361.aspx
Regards Harsh -
Scan count 17 logical reads 176543 showing in execution plan
Hello,
I am getting scan count 17 and logical reads 145634 and some time the query takes 2 minutes and sometime 5 seconds.Thelogical reads showing against a big table(Product and Orders) that is having 10 milions records.After procedure executed it gives only 7008
records as out put.
SELECT Cust.Name
FROM dbo.Customers Cust WITH (NOLOCK)
INNER JOIN Products Prod WITH (NOLOCK) ON Cust.ID = Prod.CustID
INNER JOIN dbo.Orders Ords WITH (NOLOCK) on Cust.RepID = prod.ProdId
INNER JOIN dbo.[Address] Adds WITH (NOLOCK) on Prod.id = Adds.Id
WHERE ords.pickeddate between @startdate and @enddate
Please do the needful.>>>>How to reduce logical reads against big tables?
Have a useful index/s . But please show the execution plan of the query as David pointed.
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to reduce logical count and scan count for a select query
hi,
I have two tables one is master and other is history. i need to combine this two tables into one temporary table.
I am using the below query to create temp table.
Select * into temporders
from
(select * from orders
union
select * from ordershistory) b
where updateon= (select max(updateon)from (select updateon,name,units,subunits from orders
union
select updateon,name,units,subunits from ordershistory) a
where updateon <='11/08/2008 11:18 AM' and a.name=b.name and a.units=b.units and a.subunits=b.subunits group by name,units,subunits)
order by report,subunitsorder
the statistics for this query:
SQL Server parse and compile time:
CPU time = 47 ms, elapsed time = 62 ms.
Table 'Worktable'. Scan count 556, logical reads 1569, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ORDERSHISTORY'. Scan count 116, logical reads 339, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ORDERS'. Scan count 116, logical reads 285, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 32 ms, elapsed time = 63 ms.
(115 row(s) affected)
you see logical reads and scan count for worktable(temporary) is quite high.
So anyone can give a solution for reduce the scan count and logical reads.
NOTE: name,units, subunits,updateon columns have primarykeySQL ServerAm i reading it properly? :(
This is Oracle Forum And not the SQL Server.
Regards.
Satyaki De. -
Understanding Statistics io and Logical reads - is logical reads information correct
Hi,
This question arises during a performance test - on SQL Server 2012 with SP2.
In the following example, table has only column and that is of data type INT.
When inserted 592 records of data type INT it is doing only 1 logical read but as soon another record is inserted SP is reporting 2 logical reads. Why?
In the code, i have highlighted difference between
statistics io - logical reads and sys.dm_exec_procedure_stats.total_logical_reads
to understand the difference between these 2 information.
set nocount on
GO
create table dbo.test_storage_and_logical_reads
employee_number int --primary key
GO
go
CREATE procedure dbo.test_sp_logical_reads
as
begin
select
employee_number
from dbo.test_storage_and_logical_reads
order by employee_number desc
end
go
insert into dbo.test_storage_and_logical_reads
(employee_number)
VALUES (1)
GO 592
EXEC sp_spaceused 'dbo.test_storage_and_logical_reads'
--set statistics io on
--GO
exec dbo.test_sp_logical_reads
GO
----Table 'test_storage_and_logical_reads'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
---- But sys.dm_exec_procedure_stats.total_logical_reads is reporting 3 instead.
truncate table dbo.test_storage_and_logical_reads
GO
insert into dbo.test_storage_and_logical_reads
(employee_number)
VALUES (1)
GO 593
EXEC sp_spaceused 'dbo.test_storage_and_logical_reads'
exec dbo.test_sp_logical_reads
GO
----Table 'test_storage_and_logical_reads'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
---- But sys.dm_exec_procedure_stats.total_logical_reads is reporting 4 instead.
--drop procedure dbo.test_sp_logical_reads
--drop table dbo.test_storage_and_logical_reads
GO
NB: I do understand the logical and physical reads. Thanks.
For quick review of new features, try virtual labs: http://msdn.microsoft.com/en-us/aa570323Hi.
I still need to test the scenario but if you read definition of this DMV it says 'Returns aggregate performance statistics for cached stored procedures' so I guess, I am not sure 3 can be due to this aggregated output given by this DMV. Will test it
on SS 2012 SP2 will get back to you.
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
My TechNet Wiki Articles
Hi Shanky / Sean Gallardy
i think Sean Gallardy created the "test_sp_logical_reads" table in master DB, i have that same issue when i accidentiatly created the table "test_sp_logical_reads" in master, but when i create the same table in USER DB like "sample1"
it only allocate 1 page for 592,
hi Asam,
Let me narrow down the your question, if my understanding is correct ...
<<When you have the free space in a page of a Heap, why SQL Server is assigning New page for a New Record>>
Answer is in PFS bytes
The answer is that PFS bytes are not fully reset until the page is reallocated. On deallocation, the only bit in the PFS byte that's changed is the allocation status bit - this makes it very easy to rollback a deallocation
--Before inserting the 593 record plese execute the below query
--Note Replace "database1" with your DBName
DBCC TRACEON (3604);
DBCC IND ('database1', 'test_storage_and_logical_reads', 1);
--Result
PageFID PagePID IAMFID IAMPID ObjectID IndexID PartitionNumber PartitionID iam_chain_type PageType IndexLevel NextPageFID NextPagePID PrevPageFID PrevPagePID
1 2770 NULL NULL 517576882 0 1 72057594039828480 In-row data 10 NULL 0 0 0 0
1 2769 1 2770 517576882 0 1 72057594039828480 In-row data 1 0 0 0 0 0
--your intrested in the second record(page)
DBCC PAGE ('database1', 1, 2769,3) WITH TABLERESULTS;
--you can find 38th row as
--PFS (1:1) = 0x64 MIXED_EXT ALLOCATED 100_PCT_FULL
--which means your page is full
--you can try inserting 300 rows it will show you PFS (1:1) = 0x61 MIXED_EXT ALLOCATED 50_PCT_FULL
please refer in the below link
http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/07/08/under-the-covers-gam-sgam-and-pfs-pages.aspx
http://aboutsqlserver.com/2013/12/17/sql-server-storage-engine-heap-tables/
"This page has a PFS byte value of 0x04 - how can it be full when its not allocated?"
The answer is that PFS bytes are not fully reset until the page is reallocated. On deallocation, the only bit in the PFS byte that's changed is the allocation status bit - this makes it very easy to rollback a deallocation.
Here's an example. Using a database with a simple table with one row.
A DBCC PAGE of the IAM page includes:
PFS (1:1) = 0x70 IAM_PG MIXED_EXT ALLOCATED 0_PCT_FULL
If I run the following:
BEGIN
TRANSACTION
DROP
TABLE T1
GO
And then do the DBCC PAGE again, the output now includes:
PFS (1:1) = 0x30 IAM_PG MIXED_EXT 0_PCT_FULL
And if I rollback then transaction, the DBCC PAGE output reverts to:
PFS (1:1) = 0x70 IAM_PG MIXED_EXT ALLOCATED 0_PCT_FULL
Thanks
Saravana Kumar C -
Wrong count of 'messages read' in user statistics
I added up all the messages from all the forums. Total: 489 messages.
According to 'my' statistics, so far I have already read: 2020 messages.
Slight discrepancy. Explain please.
Looks like everytime I open a thread, the posts get added to my total. HUMBUG.
Message Edited by RealBlackStuff on 12-06-2007 06:28 PMI agree.
The accounting for some of the stats may seem inflated - perhaps it is a setting, perhaps the way the software platform may give you credit for all the messages in a thread rather than just the incremental ones. We will investigate.
Hopefully most users will focus on the content, and won't get too wraped up in this aspect. I suspect it catches your eye due to your particular specialty - you have a keen eye for how well the application itself runs.
Keep kicking the tires.
ThinkPads: S30, T43, X60t, X1, W700ds, IdeaPad Y710, IdeaCentre: A300, IdeaPad K1
Mark Hopkins
Program Manager, Lenovo Social Media (Services)
twitter @lenovoforums
English Community Deutsche Community Comunidad en Español Русскоязычное Сообщество -
Hello !
Does the counter of event buffer gets include the logical reads ?
Does the mertic buffer gets include the event of reading from undo buffer ?
Thanks and regards,
Pavel
Edited by: Pavel on Jun 27, 2012 3:08 AM
Edited by: Pavel on Jun 27, 2012 3:35 AM
Edited by: Pavel on Jun 27, 2012 4:13 AMHi,
buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
For more information and some examples, see a thread at askTom:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
Best regards,
Nikolay -
I have two databases - one is a clone of the other, amde a few months ago. Database A has somewhat more data, since it's the active production database, but not significantly more - perhaps 10% greater. They are on different boxes. Database A is on a Sun 280R 2-processor box. Database B is on a Dell 2950 with 2 dual-core processors. So this isn't exactly comparing apples to apples. However, when I run the same query on the two databases, I get radically different results. Against Database A, the query takes about 7 minutes. On Database B, it takes about 2 seconds. Logical reads per second on Database A reach 80,000-90,000; on Database B, they're about 3,000. There are a few configuration differences (both databases use automatic memory management):
Database A Database B
db_file_multiblock_read_count 64 16
log_buffer 14290432 2104832
open_cursors 1250 300
sga_max_size 4194304000 536870912
sga_target 2634022912 536870912
shared_pool_reserved_size 38587596 7340032
The timings were taken off-hours so neither database would be busy. I'm baffled by the extreme difference in execution times. Any help appreciated!
Thanks,
Harry
Edited by: harryb on Apr 8, 2009 7:26 PMOK, let's start here....
Database A (TEMPOP)
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.3
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 64
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
===================================================
Database B (TEMPO11)
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
=================================================================
Now for the query that's causing the problem:
SELECT dsk_document_attribute.value_text inspect_permit_no,
NVL (activity_task_list.revised_due_date,
activity_task_list.default_due_date
inspect_report_due_date,
agency_interest.master_ai_id agency_interest_id,
agency_interest.master_ai_name agency_interest_name,
get_county_code_single (agency_interest.master_ai_id)
parish_or_county_code,
agency_interest_address.physical_address_line_1 inspect_addr_1,
agency_interest_address.physical_address_line_2 inspect_addr_2,
agency_interest_address.physical_address_line_3 inspect_addr_3,
agency_interest_address.physical_address_municipality inspect_city,
agency_interest_address.physical_address_state_code state_id,
agency_interest_address.physical_address_zip inspect_zip,
person.master_person_first_name person_first_name,
person.master_person_middle_initial person_middle_initial,
person.master_person_last_name person__last_name,
SUBSTR (person_telecom.address_or_phone, 1, 14) person_phone,
activity_task_list.requirement_id
FROM dsk_document_attribute,
agency_interest,
activity_task_list,
agency_interest_address,
dsk_central_file dsk_aaa,
dsk_central_file dsk_frm,
person,
person_telecom
WHERE agency_interest.int_doc_id = 0
AND agency_interest.master_ai_id =
agency_interest_address.master_ai_id
AND agency_interest.int_doc_id = agency_interest_address.int_doc_id
AND agency_interest.master_ai_id = dsk_frm.master_ai_id
AND dsk_aaa.int_doc_id = activity_task_list.int_doc_id
AND dsk_frm.int_doc_id = dsk_document_attribute.int_doc_id
AND dsk_frm.doc_type_specific_code =
dsk_document_attribute.doc_type_specific_code
AND dsk_frm.activity_category_code = 'PER'
AND dsk_frm.activity_class_code = 'GNP'
AND dsk_frm.activity_type_code IN ('MAB', 'NAB', 'REB')
AND dsk_frm.program_code = '80'
AND dsk_frm.doc_type_general_code = 'FRM'
AND dsk_frm.doc_type_specific_code = 'PERSET'
AND dsk_aaa.doc_template_id = 2000
AND dsk_frm.master_ai_id = dsk_aaa.master_ai_id
AND dsk_frm.activity_category_code = dsk_aaa.activity_category_code
AND dsk_frm.program_code = dsk_aaa.program_code
AND dsk_frm.activity_class_code = dsk_aaa.activity_class_code
AND dsk_frm.activity_type_code = dsk_aaa.activity_type_code
AND dsk_frm.activity_year = dsk_aaa.activity_year
AND dsk_frm.activity_num = dsk_aaa.activity_num
AND dsk_document_attribute.doc_attribute_code = 'PERMIT_NO'
AND activity_task_list.requirement_id IN ('3406', '3548', '3474')
AND activity_task_list.reference_task_id = 0
AND NVL (activity_task_list.status_code, '$$$') <> '% '
AND person.master_person_id(+) =
f_get_gp_contact (agency_interest.master_ai_id)
AND person.int_doc_id(+) = 0
AND person.master_person_id = person_telecom.master_person_id(+)
AND person.int_doc_id = person_telecom.int_doc_id(+)
AND person_telecom.telecom_type_code(+) = 'wp';Here's the explain plan for Database A, where the query takes 7-8 minutes or more:
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 253 | 34 (3)|
| 1 | NESTED LOOPS | | 1 | 253 | 34 (3)|
| 2 | NESTED LOOPS | | 1 | 224 | 32 (0)|
| 3 | NESTED LOOPS OUTER | | 1 | 169 | 31 (0)|
| 4 | NESTED LOOPS OUTER | | 1 | 144 | 29 (0)|
| 5 | NESTED LOOPS | | 1 | 122 | 27 (0)|
| 6 | NESTED LOOPS | | 1 | 81 | 26 (0)|
PLAN_TABLE_OUTPUT
| 7 | NESTED LOOPS | | 1 | 48 | 19 (0)|
| 8 | INLIST ITERATOR | | | | |
|* 9 | TABLE ACCESS BY INDEX ROWID| ACTIVITY_TASK_LIST | 1 | 21 | 17 (0)|
|* 10 | INDEX RANGE SCAN | ACTIVITY_TASK_LIST_FK11 | 106 | | 4 (0)|
|* 11 | TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE | 1 | 27 | 2 (0)|
|* 12 | INDEX UNIQUE SCAN | PK_DSK_CENTRAL_FILE | 1 | | 1 (0)|
|* 13 | TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE | 1 | 33 | 7 (0)|
|* 14 | INDEX RANGE SCAN | CF_MASTER_AI_ID_IND | 9 | | 2 (0)|
| 15 | TABLE ACCESS BY INDEX ROWID | AGENCY_INTEREST | 1 | 41 | 1 (0)|
|* 16 | INDEX UNIQUE SCAN | PK_AGENCY_INTEREST | 1 | | 0 (0)|
| 17 | TABLE ACCESS BY INDEX ROWID | PERSON | 1 | 22 | 2 (0)|
PLAN_TABLE_OUTPUT
|* 18 | INDEX UNIQUE SCAN | PK_PERSON | 1 | | 1 (0)|
| 19 | TABLE ACCESS BY INDEX ROWID | PERSON_TELECOM | 1 | 25 | 2 (0)|
|* 20 | INDEX UNIQUE SCAN | PK_PERSON_TELECOM | 1 | | 1 (0)|
| 21 | TABLE ACCESS BY INDEX ROWID | AGENCY_INTEREST_ADDRESS | 1 | 55 | 1 (0)|
|* 22 | INDEX UNIQUE SCAN | PK_AGENCY_INTEREST_ADDRESS | 1 | | 0 (0)|
| 23 | TABLE ACCESS BY INDEX ROWID | DSK_DOCUMENT_ATTRIBUTE | 1 | 29 | 1 (0)|
|* 24 | INDEX UNIQUE SCAN | PK_DSK_DOCUMENT_ATTRIBUTE | 1 | | 0 (0)|
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
9 - filter("ACTIVITY_TASK_LIST"."REFERENCE_TASK_ID"=0 AND
NVL("ACTIVITY_TASK_LIST"."STATUS_CODE",'$$$')<>'% ')
10 - access("ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3406 OR
"ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3474 OR "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3548)
11 - filter("DSK_AAA"."DOC_TEMPLATE_ID"=2000 AND "DSK_AAA"."ACTIVITY_CLASS_CODE"='GNP' AND
"DSK_AAA"."PROGRAM_CODE"='80' AND "DSK_AAA"."ACTIVITY_CATEGORY_CODE"='PER' AND
("DSK_AAA"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_AAA"."ACTIVITY_TYPE_CODE"='NAB' OR
"DSK_AAA"."ACTIVITY_TYPE_CODE"='REB'))
12 - access("ACTIVITY_TASK_LIST"."INT_DOC_ID"="DSK_AAA"."INT_DOC_ID")
13 - filter("DSK_FRM"."ACTIVITY_CLASS_CODE"='GNP' AND "DSK_FRM"."PROGRAM_CODE"='80' AND
PLAN_TABLE_OUTPUT
"DSK_FRM"."DOC_TYPE_SPECIFIC_CODE"='PERSET' AND "DSK_FRM"."ACTIVITY_CATEGORY_CODE"='PER' AND
"DSK_FRM"."DOC_TYPE_GENERAL_CODE"='FRM' AND ("DSK_FRM"."ACTIVITY_TYPE_CODE"='MAB' OR
"DSK_FRM"."ACTIVITY_TYPE_CODE"='NAB' OR "DSK_FRM"."ACTIVITY_TYPE_CODE"='REB') AND
"DSK_FRM"."ACTIVITY_TYPE_CODE"="DSK_AAA"."ACTIVITY_TYPE_CODE" AND
"DSK_FRM"."ACTIVITY_YEAR"="DSK_AAA"."ACTIVITY_YEAR" AND
"DSK_FRM"."ACTIVITY_NUM"="DSK_AAA"."ACTIVITY_NUM")
14 - access("DSK_FRM"."MASTER_AI_ID"="DSK_AAA"."MASTER_AI_ID")
16 - access("AGENCY_INTEREST"."MASTER_AI_ID"="DSK_FRM"."MASTER_AI_ID" AND
"AGENCY_INTEREST"."INT_DOC_ID"=0)
18 - access("PERSON"."MASTER_PERSON_ID"(+)="F_GET_GP_CONTACT"("AGENCY_INTEREST"."MASTER_AI_ID
") AND "PERSON"."INT_DOC_ID"(+)=0)
PLAN_TABLE_OUTPUT
20 - access("PERSON"."MASTER_PERSON_ID"="PERSON_TELECOM"."MASTER_PERSON_ID"(+) AND
"PERSON_TELECOM"."TELECOM_TYPE_CODE"(+)='wp' AND
"PERSON"."INT_DOC_ID"="PERSON_TELECOM"."INT_DOC_ID"(+))
22 - access("AGENCY_INTEREST"."MASTER_AI_ID"="AGENCY_INTEREST_ADDRESS"."MASTER_AI_ID" AND
"AGENCY_INTEREST_ADDRESS"."INT_DOC_ID"=0)
24 - access("DSK_FRM"."INT_DOC_ID"="DSK_DOCUMENT_ATTRIBUTE"."INT_DOC_ID" AND
"DSK_DOCUMENT_ATTRIBUTE"."DOC_ATTRIBUTE_CODE"='PERMIT_NO' AND
"DSK_DOCUMENT_ATTRIBUTE"."DOC_TYPE_SPECIFIC_CODE"='PERSET')============================================================================
Here's the explan plan output for Database B, where the query takes 2-3 seconds:
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
| 0 | SELECT STATEMENT | | 1 | 289 | 39 (0)|
| 1 | NESTED LOOPS OUTER | | 1 | 289 | 39 (0)|
| 2 | NESTED LOOPS | | 1 | 260 | 37 (0)|
| 3 | NESTED LOOPS | | 1 | 205 | 36 (0)|
| 4 | NESTED LOOPS OUTER | | 1 | 172 | 35 (0)|
| 5 | NESTED LOOPS | | 1 | 145 | 34 (0)|
| 6 | NESTED LOOPS | | 1 | 104 | 33 (0)|
PLAN_TABLE_OUTPUT
| 7 | NESTED LOOPS | | 1 | 61 | 26 (0)|
| 8 | INLIST ITERATOR | | | | |
|* 9 | TABLE ACCESS BY INDEX ROWID| ACTIVITY_TASK_LIST | 1 | 25 | 24 (0)|
|* 10 | INDEX RANGE SCAN | ACTIVITY_TASK_LIST_FK11 | 145 | | 4 (0)|
|* 11 | TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE | 1 | 36 | 2 (0)|
|* 12 | INDEX UNIQUE SCAN | PK_DSK_CENTRAL_FILE | 1 | | 1 (0)|
|* 13 | TABLE ACCESS BY INDEX ROWID | DSK_CENTRAL_FILE | 1 | 43 | 7 (0)|
|* 14 | INDEX RANGE SCAN | CF_MASTER_AI_ID_IND | 9 | | 2 (0)|
| 15 | TABLE ACCESS BY INDEX ROWID | AGENCY_INTEREST | 1 | 41 | 1 (0)|
|* 16 | INDEX UNIQUE SCAN | PK_AGENCY_INTEREST | 1 | | 0 (0)|
| 17 | TABLE ACCESS BY INDEX ROWID | PERSON | 8 | 216 | 1 (0)|
PLAN_TABLE_OUTPUT
|* 18 | INDEX UNIQUE SCAN | PK_PERSON | 1 | | 0 (0)|
| 19 | TABLE ACCESS BY INDEX ROWID | DSK_DOCUMENT_ATTRIBUTE | 1 | 33 | 1 (0)|
|* 20 | INDEX UNIQUE SCAN | PK_DSK_DOCUMENT_ATTRIBUTE | 1 | | 0 (0)|
| 21 | TABLE ACCESS BY INDEX ROWID | AGENCY_INTEREST_ADDRESS | 1 | 55 | 1 (0)|
|* 22 | INDEX UNIQUE SCAN | PK_AGENCY_INTEREST_ADDRESS | 1 | | 0 (0)|
| 23 | TABLE ACCESS BY INDEX ROWID | PERSON_TELECOM | 1 | 29 | 2 (0)|
|* 24 | INDEX UNIQUE SCAN | PK_PERSON_TELECOM | 1 | | 1 (0)|
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
9 - filter("ACTIVITY_TASK_LIST"."REFERENCE_TASK_ID"=0 AND
NVL("ACTIVITY_TASK_LIST"."STATUS_CODE",'$$$')<>'% ')
10 - access("ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3406 OR
"ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3474 OR "ACTIVITY_TASK_LIST"."REQUIREMENT_ID"=3548)
11 - filter("DSK_AAA"."DOC_TEMPLATE_ID"=2000 AND "DSK_AAA"."ACTIVITY_CLASS_CODE"='GNP' AND
"DSK_AAA"."PROGRAM_CODE"='80' AND "DSK_AAA"."ACTIVITY_CATEGORY_CODE"='PER' AND
("DSK_AAA"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_AAA"."ACTIVITY_TYPE_CODE"='NAB' OR
"DSK_AAA"."ACTIVITY_TYPE_CODE"='REB'))
12 - access("ACTIVITY_TASK_LIST"."INT_DOC_ID"="DSK_AAA"."INT_DOC_ID")
13 - filter("DSK_FRM"."DOC_TYPE_SPECIFIC_CODE"='PERSET' AND
PLAN_TABLE_OUTPUT
"DSK_FRM"."ACTIVITY_CLASS_CODE"='GNP' AND "DSK_FRM"."PROGRAM_CODE"='80' AND
"DSK_FRM"."DOC_TYPE_GENERAL_CODE"='FRM' AND "DSK_FRM"."ACTIVITY_CATEGORY_CODE"='PER' AND
("DSK_FRM"."ACTIVITY_TYPE_CODE"='MAB' OR "DSK_FRM"."ACTIVITY_TYPE_CODE"='NAB' OR
"DSK_FRM"."ACTIVITY_TYPE_CODE"='REB') AND "DSK_FRM"."ACTIVITY_TYPE_CODE"="DSK_AAA"."ACTIVITY_TY
PE_CODE" AND "DSK_FRM"."ACTIVITY_YEAR"="DSK_AAA"."ACTIVITY_YEAR" AND
"DSK_FRM"."ACTIVITY_NUM"="DSK_AAA"."ACTIVITY_NUM")
14 - access("DSK_FRM"."MASTER_AI_ID"="DSK_AAA"."MASTER_AI_ID")
16 - access("AGENCY_INTEREST"."MASTER_AI_ID"="DSK_FRM"."MASTER_AI_ID" AND
"AGENCY_INTEREST"."INT_DOC_ID"=0)
18 - access("PERSON"."MASTER_PERSON_ID"(+)="F_GET_GP_CONTACT"("AGENCY_INTEREST"."MASTER_AI_ID
") AND "PERSON"."INT_DOC_ID"(+)=0)
PLAN_TABLE_OUTPUT
20 - access("DSK_FRM"."INT_DOC_ID"="DSK_DOCUMENT_ATTRIBUTE"."INT_DOC_ID" AND
"DSK_DOCUMENT_ATTRIBUTE"."DOC_ATTRIBUTE_CODE"='PERMIT_NO' AND
"DSK_DOCUMENT_ATTRIBUTE"."DOC_TYPE_SPECIFIC_CODE"='PERSET')
22 - access("AGENCY_INTEREST"."MASTER_AI_ID"="AGENCY_INTEREST_ADDRESS"."MASTER_AI_ID" AND
"AGENCY_INTEREST_ADDRESS"."INT_DOC_ID"=0)
24 - access("PERSON"."MASTER_PERSON_ID"="PERSON_TELECOM"."MASTER_PERSON_ID"(+) AND
"PERSON_TELECOM"."TELECOM_TYPE_CODE"(+)='wp' AND
"PERSON"."INT_DOC_ID"="PERSON_TELECOM"."INT_DOC_ID"(+))===============================================================================
Edited by: harryb on Apr 9, 2009 3:29 PM -
Find physical reads and logical reads ?
Hi,
how will find out physical reads and logical reads ?Well I would suggest you read the report from statspack/awr.They as suggested by Amit,have a load profile section.That would be helpful for you in finding the details of this thing. Also which version you are? If you are in 10g than the EM is able to give you a compare period report where you can compare 2 different days's periods information and can check which particular part has changed.
In addition to this , look for the information of the metrics in the documentation.As the physical read and logical reads are statistics which are happening in the system.So from 10g onwards, oracle is keeping a track in the deflectionin the statistics. So if you see that than it willbe easy for you to manage and monitor it.
I shall try to findthe name of some views related to it and post.
Aman.... -
Physical reads, writes and logical reads,writes
hi there,
is there any way to find the physical reads and writes, logical reads and writes
other than statspack report?It depends which version of Oracle are you using.
If you are using 10g, you can get very comprehensive information from the dictionary views.
If you are on <=9i, then, use, v$sysstat and look for 'physical reads', 'logical reads'.
The values dervied from v$sysstat are cummulative values. i.e. values counted since the instance started.
Jaffar -
Buffer_gets and 'session logical reads'
When I compare the following values:
select sum(buffer_gets) from v$sqlarea
and
select value from v$sysstat where name='session logical reads'
it usually happens that sum(buffer_gets) > 'session logical reads'.
Does buffer_gets include logical and physical reads? As long as the SGA keeps all the SQL statments, I guess sum(buffer_gets) will be bigger than 'session logical reads'. Is this correct?
ThxsHi,
buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
For more information and some examples, see a thread at askTom:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
Best regards,
Nikolay -
Logical Reads are very high when run as sproc and very less logical reads when run as a script
Hello
Have a question,
when i execute a sproc. i get a very high logical reads count and when i run the same sproc converted into script it has very low logical reads what does it mean..I would like you to check query plan during ad-hoc run versus stored procedure execution. As other pointed out it could be due to parameter sniffing.
Balmukund Lakhani
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
This posting is provided "AS IS" with no warranties, and confers no rights.
My Blog |
Team Blog | @Twitter
| Facebook
Author: SQL Server 2012 AlwaysOn -
Paperback, Kindle -
AWR's buffer cache reads and logical reads
In AWR report under "Segments by Logical Reads" section, there is a total logical reads, I assume it is in unit of block. Under "IOStat by Function summary" section, it has buffer cache reads in unit of bytes. Shouldn't the number of logical reads x 8k (if the block size is 8k) = the number of buffer cache reads?
They are not equal, not even close, does anybody know why? ThanksHi,
buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
For more information and some examples, see a thread at askTom:
http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
Best regards,
Nikolay -
Logical reads VS physical reads
hello all,
What is the difference between logical reads and physical read ??? I do get the part of logical read (from buffer) and physical read(from disk). And also do know physical reads are bad, but is it true in oracle world..logical reads are bad ??? if so why ??? Could you please explain which on to look for. As i am going thru AWR report and i see segemts by logical/physical read.The first and foremost difference is that physcial reads are done from the hard disk. And this is always going tobe slwoer than the memory. That's why its said that the physcial ios must be removed. Logical ios are good as they are done from the memory.The theory that logical are also not good is because the logical ios require the access given by latches. So with lots of the gets for the latches put them in to contention and latch contention would make the access to the logical io slower.So its better to do this in less IO even they are logical too.
Lots of logical IOs probably mean that you are accessing unnecessary data which may be not required.
HTH
Aman.... -
Dear Experts,
Any idea how we can find out Logical reads for a SQL ID over a 24 hour period? AWR shows physical reads info.. any data dictionary view that captures logical I/O?
ThanksFigured it out.. This is it:
col Time_Taken for 999999999999
col log_reads for 9999999999999
select sql_id, sum(disk_reads_delta) as phy_reads, sum(BUFFER_GETS_DELTA) as log_reads, sum(ELAPSED_TIME_DELTA/1000000) as Time_Taken
from dba_maint.DB_HIST_SQLSTATS
where PARSING_SCHEMA_NAME='USERNAME' and BEGIN_INTERVAL_TIME>='03-JAN-13' and sql_id in ('abcdefghijkl')
group by sql_id order by phy_reads, log_reads, time_taken desc;
Maybe you are looking for
-
When I print, a last page is printed with a summary of document printed - file name, directory, ... Just got Windows 8. Is this something I can stop? Waste of paper and ink!!
-
Posting / Due / Document date trouble
Hi there, i have a little bit trouble with the dates. I already read a sheet about dates in SAP, but there are some misunderstandings. Here is the scenario, in which i have problems : I book a incoming payment ( Posting date : 15.11.2008 | due date :
-
Can't create AMStoreConnection object
The usual story trying to manage the AM froma client application User Authentication is okay and so is the SSOToken as I can see that the user is loged in in the active sessions tab. Once I try to create the AMStoreConnection I get the following erro
-
Create items by vendor and customer on Foreign Currency Valuation
When we execute Foreign Currency Valuation, we would like to create items in a document by vendor and customer. Can we handle it a 'Corp.group-vendors' flag(Evaluate Accounts According to Group Definition) ? Can you help with this issue please? Thank
-
Automatic delivery date change based on logistics calendar
Dear Experts, I have a certain plant for which i have 5 days working & for the rest i have all days working . My requirement is that the system should find out & change the delivery date in PO automatically , if the delivery date falls on a holiday .