niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Improving sql speed
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Galen Boyer
*nix forums Guru Wannabe


Joined: 24 Mar 2005
Posts: 106

PostPosted: Sun Feb 27, 2005 10:37 pm    Post subject: Re: Improving sql speed Reply with quote

On 26 Feb 2005, upulbhradia@yahoo.com wrote:
Quote:


I audit changes in columns with XML. Any changes are approved but I
need to find how many changes are not.

This query is slow. Can I speed it?

select count(*) from debtors3Y where like
'<audit><x1><a9004><authorID%' and not like
'<audit><x1><a9004><authorID%<approved%';

What you are currently attempting has nothing to do with XML and all
about speeding up "like" queries. To take advantage of XML you can
submit an XMLSchema to Oracle and then Oracle will shred your XML into a
performant structure which you apply XML queries against, and I'm
talking about Oracle XML support.

ie, if you are going to go XML route in the database, then use the XML
support offered by the database.
--
Galen deForest Boyer
Back to top
Michael O'Shea
*nix forums beginner


Joined: 01 May 2005
Posts: 22

PostPosted: Sat Feb 26, 2005 3:20 pm    Post subject: Re: Improving sql speed Reply with quote

Upul, there is not much to go on from what you have posted. To help you
out in any level of detail you will have to post a snippet of your XML
schema, Oracle version, etc.

Anyway, the query as you have written it is not scalable and I am not
surprised you are having performance problems. I also have the distinct
impression you are storing the information in a datatype of VARCHAR2 or
CLOB. For best results you will find the XMLTYPE datatype and XPATH
expressions appropriate here. The relevant Oracle documentation search
term is XMLDB.

In addition to missing the column name in your SQL snippet posting,
note too that what you have written is bugged. Wildcard searching the
XML for '...%<approved' does not tell you whether the tag present or
not in the XML! What if, for example, the XML contained "<approved/>"
or "<approved></approved>". Accordingly to the XML grammar, both are
still missing "approved" content yet would be included in the total
returned by the execution of your SQL statement.

As an interim answer, I feel you are possibly asking for a query of
this nature.

SELECT COUNT(*)
FROM debtor3y
WHERE NOT EXTRACTVALUE(put table column name in
here,'/audit/x1/a9004[count(*)=1]/authorID') IS NULL;

Enhance/refine the XPATH expression as necessary. This type of
construct can also be used to retrieve, for example, the author ID's in
your XML. You don't want to be using SUBSTR.

Eg,


SELECT EXTRACTVALUE(put table column name in
here,'/audit/x1/a9004/authorID')
FROM debtor3y;

Regards
Mike

TESSELLA Michael.OShea@tessella.com
__/__/__/ Tessella Support Services plc
__/__/__/ 3 Vineyard Chambers, ABINGDON, OX14 3PX, England
__/__/__/ Tel: (44)(0)1235-555511 Fax: (44)(0)1235-553301
www.tessella.com Registered in England No. 1466429



U Radia wrote:
Quote:
I audit changes in columns with XML. Any changes are approved but I
need to find how many changes are not.

This query is slow. Can I speed it?

select count(*) from debtors3Y where like
'<audit><x1><a9004><authorID%' and not like
'<audit><x1><a9004><authorID%<approved%';

Upul
Back to top
DA Morgan
*nix forums Guru


Joined: 06 Mar 2005
Posts: 1042

PostPosted: Sat Feb 26, 2005 2:58 pm    Post subject: Re: Improving sql speed Reply with quote

U Radia wrote:
Quote:

I audit changes in columns with XML. Any changes are approved but I
need to find how many changes are not.

This query is slow. Can I speed it?

select count(*) from debtors3Y where like
'<audit><x1><a9004><authorID%' and not like
'<audit><x1><a9004><authorID%<approved%';

Upul

The easiest way to speed it up would be to store the XML
relationally and then reconstitute it on demand if required.

Doing so will also save a lot of disk space.

BTW: What version of Oracle?
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Back to top
U Radia
*nix forums beginner


Joined: 26 Feb 2005
Posts: 1

PostPosted: Sat Feb 26, 2005 1:41 pm    Post subject: Improving sql speed Reply with quote

I audit changes in columns with XML. Any changes are approved but I
need to find how many changes are not.

This query is slow. Can I speed it?

select count(*) from debtors3Y where like
'<audit><x1><a9004><authorID%' and not like
'<audit><x1><a9004><authorID%<approved%';

Upul
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 6:13 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts CD/DVD Drive Speed John Howell Suse 0 Fri Jul 21, 2006 10:43 am
No new posts Speed problem Andreas Schmitt C++ 7 Thu Jul 20, 2006 3:19 am
No new posts eth manual setting of speed and duplex hakim Debian 0 Wed Jul 19, 2006 3:40 pm
No new posts function taking a long time. any options o speed it up. Rhys Stewart PostgreSQL 2 Tue Jul 18, 2006 1:11 pm
No new posts Very simple speed benchmark of few string substitions ways Rafal Zawadzki python 1 Sun Jul 16, 2006 3:57 pm

Debt Consolidation | Online Advertising | Credit Cards | Best Search Engine | MPAA
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1165s ][ Queries: 20 (0.0336s) ][ GZIP on - Debug on ]