473,486 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Performance Issue when substr used in where clause

4 New Member
After researching a problem with a report I found that the fields used in the where clause did not equal because of some data conversion done on one of the tables. During the conversion one of the fields was prefixed with "50".
So now A.Field does not equal B.Field.

So I decided that I would add "WHERE substr(A.Field,3,15) = B.Field". The system timed out on me.

I read in another forum to add an index, but I don't have permissons to do so. I am just troubleshooting and trying to fix a crystal report.

Thank you in advance...please advise.
Jun 6 '12 #1
7 8760
Rabbit
12,516 Recognized Expert Moderator MVP
Try a like with wildcards instead. That tends to run faster than a substring function.
Jun 6 '12 #2
Rattler1887
4 New Member
@Rabbit
I don't think the wildcard is going to help me out, I changed it and it's still running...It's been running for the last 12 minutes
Jun 6 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Show us what you changed it to.

If the like operator isn't any faster than the substring and your're not allowed to add indexes, there's nothing else you can do.
Jun 6 '12 #4
Rattler1887
4 New Member
@Rabbit
Thanks Rabbit. My original where clause is comparing to fields. When I changed the statement to use wild card it was for a specific case number..., i.e.

[WHERE A.FIELD LIKE '%1999AP000198AXX%'] I guess my statement would be [WHERE A.FIELD LIKE B.FIELD]
Jun 6 '12 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Well it would be
Expand|Select|Wrap|Line Numbers
  1. WHERE A.FIELD LIKE '%' + B.FIELD + '%'
But if it's not running any faster, there's no point.
Jun 6 '12 #6
Rattler1887
4 New Member
Thank Rabbit, I appreciate your time. I am going to have to get the DBA to create an index for me and you are correct in that the wild card run's faster than the substr. I timed them both and the wild card cut off about 15 minutes...but overall time is still not acceptable.
Jun 7 '12 #7
sbyna
1 New Member
Use REGEXPR_INSTR function
Regards,
Sekhar
Apr 24 '15 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
14654
by: Christian | last post by:
HI, I have a function that is used to constrain a query: Select COl1, Col2 From MyTable WHERE col1 = ... AND col2 = ... And MyFunction(col1) = ... My problem is that MyFunction is executed...
3
5203
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
4
1698
by: Benjamin Joldersma | last post by:
Hi all, If I have a expensive public property that exposes a collection, say via a call to a database: public ArrayList Complex { get { //expensive call to db
1
1340
by: bob | last post by:
Currently i'm writing some low level communication modules in C++ and is thinking of putting it into a library so that it can be used in C#. My concern is the performance issue when putting C++...
1
2183
by: Wim | last post by:
Hi Everyone, I'm trying to speed up a Asp.net 1.1 applications' performance. The application needs to run in an environment with little bandwith and therefore pagesizes and roundtrip times shoud...
1
2801
by: None | last post by:
Hi, I have developed webshop application using asp.net 1.1. I'm using DataGrid in one of the pages of my site. During the page load the DataGrid will be binded by around 7500 products(rows). At...
10
4257
by: shsandeep | last post by:
The ETL application loaded around 3000 rows in 14 seconds in a Development database while it took 2 hours to load in a UAT database. UAT db is partitioned. Dev db is not partitioned. the...
6
5018
by: Jared | last post by:
Consider the following two functionally identical example queries: Query 1: DECLARE @Name VARCHAR(32) SET @Name = 'Bob' SELECT * FROM Employees WHERE = CASE WHEN @Name IS NULL THEN ELSE...
4
3877
by: laurenquantrell | last post by:
Is there an equivalant construction to the CASE WHEN statement that can be used in the WHERE clause? For example, this works: SELECT FirstName = CASE WHEN c.FirstName = 'Bob' THEN 'Robert'...
12
25066
by: =?ISO-8859-1?Q?Ren=E9?= | last post by:
Hi, is there a rule of thumb what is better/faster/more performant in SQL Server 2005? a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND B.Cond2 = 2 b) SELECT * FROM A INNER...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7123
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6839
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3066
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.