Contractor UK Bulletin Board  PayStream

Go Back   Contractor UK Bulletin Board > Contractor UK Forums > Technical
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 10th July 2008, 14:58   #11
DimPrawn
Godlike
 
DimPrawn's Avatar
 
Join Date: Jul 2005
Posts: 10,425
Default

Actually, I was thinking that the SQL using the OR and LIKE and SUBSTR is not going to be very efficient and is going to scan the data.

I am thinking of maintaining another column (via a trigger) to contain the first letter of the band name and if it is not a letter, store # in the field, so the SQL becomes:

SELECT band_name
FROM bands
WHERE band_name_begins = @p

And put an index on this column, as the data is rarely updated or added to, but read A LOT.
__________________
Last week I cashed a cheque and the bank bounced.
DimPrawn is offline   Reply With Quote
Old 10th July 2008, 15:07   #12
dang65
Fingers like lightning
 
Join Date: Nov 2005
Posts: 754
Default

There are no good bands which start with a number anyway. I'd just dump them all if I was you.
dang65 is offline   Reply With Quote
Old 10th July 2008, 15:08   #13
dang65
Fingers like lightning
 
Join Date: Nov 2005
Posts: 754
Default

Apart from 3 Mustaphas 3.
dang65 is offline   Reply With Quote
Old 10th July 2008, 15:08   #14
Moscow Mule
Super poster
 
Join Date: Mar 2007
Location: London
Posts: 4,062
Default

Quote:
Originally Posted by DimPrawn View Post
That's in module 2, to be learned next week.
You are Bob Shawadiwadi AICMFP

Quote:
Originally Posted by DimPrawn View Post
Actually, I was thinking that the SQL using the OR and LIKE and SUBSTR is not going to be very efficient and is going to scan the data.

I am thinking of maintaining another column (via a trigger) to contain the first letter of the band name and if it is not a letter, store # in the field, so the SQL becomes:

SELECT band_name
FROM bands
WHERE band_name_begins = @p

And put an index on this column, as the data is rarely updated or added to, but read A LOT.
Steady now, you'll start to look like a professional (and I don't mean Bodie or Doyle).
__________________
Level 20 Xeno Geek.
Moscow Mule is offline   Reply With Quote
Old 10th July 2008, 15:27   #15
lilelvis2000
Contractor Among Contractors
 
lilelvis2000's Avatar
 
Join Date: Jul 2005
Location: the centre of the world - according to Jack Straw
Posts: 1,692
Default

How many bands are you tracking? 100K? 1M? wow!

Besides you could just make a function index in oracle, or calculated column in SQL server and index it.
lilelvis2000 is offline   Reply With Quote
Old 10th July 2008, 17:32   #16
DimPrawn
Godlike
 
DimPrawn's Avatar
 
Join Date: Jul 2005
Posts: 10,425
Default

Actually it's not bands. I just used that as an example.
__________________
Last week I cashed a cheque and the bank bounced.
DimPrawn is offline   Reply With Quote
Old 10th July 2008, 17:47   #17
NickFitz
Super poster
 
NickFitz's Avatar
 
Join Date: Jun 2007
Location: Your local branch
Posts: 2,779
Default

Quote:
Originally Posted by DimPrawn View Post
Actually it's not bands. I just used that as an example.
This is why one should use metasynctactic variables:
"Say you want to select all the rows in table "foo" having a value in the varchar field "bar" beginning with a specific character from a particular range of characters, or beginning with any character not in that range if some wildcard character is specified..."
That way people don't get distracted talking about nonsense like "How many bands are there in the world" and suchlike - they remain focused on solving the specific problem for the abstract case.
NickFitz is offline   Reply With Quote
Old 11th July 2008, 08:05   #18
EvilWeevil
Lurker not a fighter
 
Join Date: Mar 2008
Posts: 74
Default

Have you considered...

SELECT band_name
FROM bands
WHERE band_name like (replace(@p,'#','[0-9]')+'%')
EvilWeevil is offline   Reply With Quote
Old 22nd July 2008, 11:44   #19
PRC1964
Contractor Among Contractors
 
PRC1964's Avatar
 
Join Date: Jul 2005
Location: Behind you
Posts: 1,631
Default

Quote:
Originally Posted by NickFitz View Post
This is why one should use metasynctactic variables:
"Say you want to select all the rows in table "foo" having a value in the varchar field "bar" beginning with a specific character from a particular range of characters, or beginning with any character not in that range if some wildcard character is specified..."
That way people don't get distracted talking about nonsense like "How many bands are there in the world" and suchlike - they remain focused on solving the specific problem for the abstract case.
I tend to create tables called "Select" with fields called "From" and "Order By".

It confuses the hell out of everyone else though.
__________________
I need a new sig.
PRC1964 is offline   Reply With Quote
Old 22nd July 2008, 11:48   #20
DimPrawn
Godlike
 
DimPrawn's Avatar
 
Join Date: Jul 2005
Posts: 10,425
Default

Quote:
Originally Posted by EvilWeevil View Post
Have you considered...

SELECT band_name
FROM bands
WHERE band_name like (replace(@p,'#','[0-9]')+'%')
No. A good concise answer.
__________________
Last week I cashed a cheque and the bank bounced.
DimPrawn is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT. The time now is 06:54.


Advertisers
PayStream

CUK Navigation

Contractor Alliance
Formed a new Ltd Co?

20% off business insurance
£10 off Bauer & Cottrell contract reviews
Find co-workers & client introductions

Increase your value to clients here

Fast Company Formation
Same day online company formation £75 + VAT

Form your Ltd Co Here

Contractor Services


 
Content Relevant URLs by vBSEO 2.4.0 © 2005, Crawlability, Inc.