jvoconnell
asked on
Newbie quesion about ROWID in a query
Experts, I have a newbie Question regarding ROWID
I am new to Oracle and I am picking up where someone left off and this person isn't here to ask any questions. I have this query that takes hours to complete. The table only has 130,000 records in it. The query creates a final table which ends up with around 36,000 records.
So, a couple of questions. What exactly is ROWID? I'm really not sure what is being accomplished by using the MIN(ROWID)? Is there a better way to get to my end result? As I said it takes hours for this to complete.
If this is really basic, I apologize. I did try to research this on my own first but I can't make sense out of it. Not a lot of SQL people here.
Thanks in advance.
CREATE TABLE TBL_FINAL AS
(
Select A.*
FROM TBL A
WHERE A.ROWID
IN (
SELECT MIN(B.ROWID)
FROM TBL B
WHERE A.PATIENT_ID = B.PATIENT_ID
)
)
I am new to Oracle and I am picking up where someone left off and this person isn't here to ask any questions. I have this query that takes hours to complete. The table only has 130,000 records in it. The query creates a final table which ends up with around 36,000 records.
So, a couple of questions. What exactly is ROWID? I'm really not sure what is being accomplished by using the MIN(ROWID)? Is there a better way to get to my end result? As I said it takes hours for this to complete.
If this is really basic, I apologize. I did try to research this on my own first but I can't make sense out of it. Not a lot of SQL people here.
Thanks in advance.
CREATE TABLE TBL_FINAL AS
(
Select A.*
FROM TBL A
WHERE A.ROWID
IN (
SELECT MIN(B.ROWID)
FROM TBL B
WHERE A.PATIENT_ID = B.PATIENT_ID
)
)
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
wow. I totally misread the TBL A, TBL B as TBLA, TBLB.
YANNOS - thanks for the clarification & education.
jvoconell - Please reassign the solution & pts to yannos.
YANNOS - thanks for the clarification & education.
jvoconell - Please reassign the solution & pts to yannos.
ASKER
Thank you both. I have requested to re-open the question so I can assign the points differently.
dssdba - Your response did help my understanding of ROWID. Your thought that the query should be re-written was the answer I was hoping for becasue of the poor performace I was getting.
YANNOS - Your example was very helpful. Your explanation was exactly the scenario I had.
I am going to post another Newbie follow up question regarding the answere YANNOS gave.
Thanks again to both of you.
dssdba - Your response did help my understanding of ROWID. Your thought that the query should be re-written was the answer I was hoping for becasue of the poor performace I was getting.
YANNOS - Your example was very helpful. Your explanation was exactly the scenario I had.
I am going to post another Newbie follow up question regarding the answere YANNOS gave.
Thanks again to both of you.
ASKER