Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Lingering query cannot process

sono99Oct 20 2009 — edited Oct 21 2009
Hi, I need some help tracking the reason behind the lingering of a Create Table as Select STATEMENT;

Something is hapening, most probably some locks have been aquired and never released by the server.

First of, i am runing queries against a database server with one client: myself. All the queries it runs are ordered by me.

I cannot make any sense of what is making my query sometimes run, and others not.


The query I am trying to run:

--------
CREATE TABLE FAVFRIEND
NOLOGGING TABLESPACE TARGET
AS
SELECT USRID, FAVF
FROM (
SELECT ID AS USRID, FAVF
FROM PROFILE P
MODEL
PARTITION BY (ID)
DIMENSION BY (1 as FINDEX)
MEASURES (FAVF1, FAVF2, FAVF3, FAVF4, FAVF5, 0 AS FAVF)
RULES (
FAVF[1] = FAVF1[1],
FAVF[2] = FAVF2[1],
FAVF[3] = FAVF3[1],
FAVF[4] = FAVF4[1],
FAVF[5] = FAVF5[1]
)
) FAVFRIEND
WHERE FAVF IS NOT NULL
;
--------

The query Is syntatically correct, and has finished more than once.
Before this query is run my program launches sqlplus with a script that performs

-------
DROP TABLE FAVFRIEND PURGE;

QUIT;
--------

After this I snapshot a set of statistics. That do not involve querying neither the PROFILE table, nor the FAVFRIEND table.

Finally I order the execution of this query, and most times, it just hangs there not doing any processing.
I can tell with certanty that all the other sql I have sent to the database has finished execution.
1) because it was processed via sqlplus, which always disconnects after processing a batch.
2) because I run the following query:
-----
select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text
from v$session s join v$sqltext_with_newlines q on s.sql_address = q.address
where status='ACTIVE'
and s.username = 'SONO99'
and type <>'BACKGROUND'
and last_call_et> 0
order by sid,serial#,q.piece
-----

Which tells me that the only query sono99 (my user) is running, is the CREATE TABLE as SELECT.

Furthermore, the exact same procedure that isn't working for this query has worked before with the Unpivot query and the Select Project and Union queries.
The only thing that changed from the previous benchmakrs to this one is that this one involves the model query.


Another piece of information, let's say my sqlplus is haning there... trying to execute the Model query that just does not run. I kill sqlplus. Instantly when i query Oracle for the lingering queries with the select from v%session and sql_text, I notice that my CREATE TABLE with model is no longer there. So: disconnecting from the database is enough for oracle to know that the client is no longer interested in a server response.

After making sure nothing from sono99 is runing against the database, i try to DROP FAVFRIEND TABLE PURGE;
The statement fails because no FAVFRIEND table was created. And finally i wonder: could it be that the PROFILE table that was only selected upon was locked?
Well, i try to drop the profile table... and it drops.

So: my conclusion is! No locks exist neither on the Profile table nor on the Database object Favfriend (which does not exist at the point that i issue the execution of this query). Possibly some temporary tablespace was aquired by the Model query that has not been made available by oracle at the End of a previous successful CRETE TABLE as select statement.
But even if this was the case, any locks should have been released because I always restart the database before going into the
snapshot
create table as select
snapshot.

I have no idea what may be making oracle not process my statement.



Something else that I have just tried:
Now I just tried bulk loading the 5 million rows of data into the Profile table, and runing the query again.
The data was of course inserted successfully, and the query is of course still hanging.
I tried however, in parallel to run a second query, this one just performing a SELECT count(*) FROM PROFILE, and it succeeded doing so.
A Select NAME FROM PROFILE WHERE ID=500000 also returns a result.
The profile table is definably not the issue here.

by the way i just exported to a txt the status of my haning oracle system, and it looks like this:
------
"USERNAME" "SID" "SERIAL#" "MINS_RUNNING" "SQL_TEXT"
"SONO99" "140" "40" "10,9" "CREATE TABLE FAVFRIEND
NOLOGGING TABLESPACE TARGET
AS
SELECT USR"
"SONO99" "140" "40" "10,9" "ID, FAVF
FROM (
SELECT ID AS USRID, FAVF
FROM PROFILE P
MODEL"
"SONO99" "140" "40" "10,9" "
PARTITION BY (ID)
DIMENSION BY (1 as FINDEX)
MEASURES (FA"
"SONO99" "140" "40" "10,9" "VF1, FAVF2, FAVF3, FAVF4, FAVF5, 0 AS FAVF)
RULES (
FAVF[1]"
"SONO99" "140" "40" "10,9" " = FAVF1[1],
FAVF[2] = FAVF2[1],
FAVF[3] = FAVF3[1],
FA"
"SONO99" "140" "40" "10,9" "VF[4] = FAVF4[1],
FAVF[5] = FAVF5[1]
)
) FAVFRIEND
WHERE F"
"SONO99" "140" "40" "10,9" "AVF IS NOT NULL
"
-------


This is way beyond my comprehention of Oracle. Going to try to run this again with 100 k tuples instead.

Edited by: user10282047 on Oct 20, 2009 12:05 PM


Now, trying the same process, without even restarting the database once (i just killed the lingering sqlplus connection) and recreated the profile table with 100k tuples. It executed successfuly my query. I am starting to think that this problem has something to with oracle and the number of threads it tries to created to run a modal query with 5 Million partitions. But if it is so, it shouldn't work sometimes and others not.

Edited by: user10282047 on Oct 20, 2009 12:23 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2009
Added on Oct 20 2009
3 comments
309 views