473,387 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Performance Issue when substr used in where clause

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

✓ answered by Rabbit

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.

7 8751
Rabbit
12,516 Expert Mod 8TB
Try a like with wildcards instead. That tends to run faster than a substring function.
Jun 6 '12 #2
@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 Expert Mod 8TB
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
@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 Expert Mod 8TB
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
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
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
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...

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.