Home » RDBMS Server » Performance Tuning » Query using rownum in where cluase with millions of records (Oracle 11g , Windows)
Query using rownum in where cluase with millions of records [message #485580] Wed, 08 December 2010 23:10 Go to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

There is a table in Database with millios of records and a query --- Select rowid, ANI, DNIS, message from tbl_sms_talkies where rownum<=:"SYS_B_0" ---- using the high CPU and also this query having high number of executions.

Help me to resolve this query performance issue with the database.

Regards

Pradeep
Re: Query using rownum in where cluase with millions of records [message #485581 is a reply to message #485580] Wed, 08 December 2010 23:14 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/m/433888/136107/#msg_433888
Please refer to URL above & be sure to provide the details requested:
Re: Query using rownum in where cluase with millions of records [message #485585 is a reply to message #485581] Wed, 08 December 2010 23:44 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

I am sending the file in which query and plan exist.


Thanks

Pradeep
  • Attachment: Noname2.txt
    (Size: 127.29KB, Downloaded 1509 times)
Re: Query using rownum in where cluase with millions of records [message #485587 is a reply to message #485585] Wed, 08 December 2010 23:47 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
CREATE TABLE TBL_SMS_TALKIES
(
ANI VARCHAR2(12 BYTE),
DNIS VARCHAR2(12 BYTE),
MESSAGE VARCHAR2(500 BYTE)
)
TABLESPACE USERS
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 14M
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
LOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
Re: Query using rownum in where cluase with millions of records [message #485601 is a reply to message #485580] Thu, 09 December 2010 00:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Given your query and exceution plan, nothing can be done.
Maybe create a KEEP buffer pool and put the table in it.

Regards
Michel
Re: Query using rownum in where cluase with millions of records [message #485605 is a reply to message #485601] Thu, 09 December 2010 00:54 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

Please let me know how I can create the keep pool. As per my knowlage I can keep this table using

Alter table tname storage ( buffer_pool keep );

command. If there is any else to do Please specify.

Regards

Pradeep
Re: Query using rownum in where cluase with millions of records [message #485608 is a reply to message #485605] Thu, 09 December 2010 01:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Then just set "buffer_pool_keep" to a value large enough to contain your whole table (which is not large as per your statements statistics, if they are up to date) and restart the instance.

Regards
Michel
Re: Query using rownum in where cluase with millions of records [message #485666 is a reply to message #485608] Thu, 09 December 2010 06:20 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

As you said I have tried to take that table in keep pool. but I didn't get any performance related success with this. I am sending the statistics of query before and after placing the table in keep pool.

Before keeping this table Statistics is as follows ==
Execution Plan
----------------------------------------------------------
Plan hash value: 2362346581

--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time|
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 21 | 3549 | 136 (0)| 00:00:02 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | TABLE ACCESS FULL| TBL_SMS_TALKIES | 21 | 3549 | 136 (0)| 00:00:02 |
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - filter(ROWNUM<=1000)

Statistics
----------------------------------------------------------
123 recursive calls
0 db block gets
1776 consistent gets
4 physical reads
0 redo size
1844 bytes sent via SQL*Net to client
520 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
0 sorts (disk)
6 rows processed
=================================================================
After taking table in keep pool using the below command
alter table tbl_sms_talkies storage (buffer_pool keep);
statistics is as follows

Execution Plan
----------------------------------------------------------
Plan hash value: 2362346581

--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 21 | 3549 | 136 (0)| 00:00:02 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | TABLE ACCESS FULL| TBL_SMS_TALKIES | 21 | 3549 | 136 (0)| 00:00:02 |
--------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

1 - filter(ROWNUM<=1000)


Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
1761 consistent gets
0 physical reads
0 redo size
517 bytes sent via SQL*Net to client
509 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed


So Please suggest what else we can do in this issue..

Regards

Pradeep Sharma
Re: Query using rownum in where cluase with millions of records [message #485685 is a reply to message #485666] Thu, 09 December 2010 08:20 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>There is a table in Database with millios of records and a query
You state above & Oracle reports below
>| 2 | TABLE ACCESS FULL| TBL_SMS_TALKIES | 21 | 3549 | 136 (0)| 00:00:02 |

Why the HUGE difference between millions & 21?
When was TBL_SMS_TALKIES made?
Re: Query using rownum in where cluase with millions of records [message #485697 is a reply to message #485580] Thu, 09 December 2010 08:59 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

This is due to the explain taken after the unneccessary number of rows from deleted after taking backup of full table. Might be at that time only few thousand records will exist.

This table is growing so fastly.

This table was created approximate 7-8 months back.

Regards

Pradeep
Re: Query using rownum in where cluase with millions of records [message #485730 is a reply to message #485697] Thu, 09 December 2010 11:53 Go to previous message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't understand, how many rows is this table? How is it used (load then bulk delete, or insert,update...)? Detail.

Regards
Michel
Previous Topic: Creating index on base tables of a view
Next Topic: What are the best practices with indexes?
Goto Forum:
  


Current Time: Sat Apr 27 09:07:06 CDT 2024