Re: Aggregate string concatenation efficiency problem
- From: Rich P <rpng123@xxxxxxx>
- Date: Wed, 30 Jan 2008 17:39:24 -0600
I think I am starting to see the problem. Well, actually, I know what
the essential problem is -- you are calling a function that is using a
loop. If you have a lot of records, that loop will be called for each
record. Thus, Loops in sql is a bad thing.
Issue: Column5 -- it looks like you want to list multiple consultants
for each customer - on the same record. If this is the case then you
are defeating the whole concept of Normalization/RDBMS. If you are
trying to list customer information to include each consultant that has
interacted with the customer, you should retrieve a distinct row for
each consultant for each customer rather than concatenate a bunch of
names in the query. Here is my pseudo code for your query
Select t1.CustName, ... , t5.Consultant, ... From ((Customers t1 Join
tblB t2 on t1.ID = t2.ID) Join Vehicles t3 On t1.ID = t3.ID) Join
Consultants t5 On t1.ID = t5.ID Where t1.CustWhatever = 'something' And
...
If this returns duplicate records then use the "Distinct" keyword
Select Distinct t1.CustName, ... , t5.Consultant, ... From ((Customers
t1 Join tblB t2 on t1.ID = t2.ID) Join Vehicles t3 On t1.ID = t3.ID)
Join Consultants t5 On t1.ID = t5.ID Where t1.CustWhatever = 'something'
And ...
Once you have the resultset then you can manipulate your data for
presentation. If you can't join the Consultants table then you need to
re-evaluate the design of your application, and make it so that you can
join the required tables. The concept here is something about 3rd
Normal form. The goal is to prevent data duplication and redundant data
processing.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- References:
- Prev by Date: Re: Aggregate string concatenation efficiency problem
- Next by Date: Re: Validating data on a subform
- Previous by thread: Re: Aggregate string concatenation efficiency problem
- Next by thread: Re: Aggregate string concatenation efficiency problem
- Index(es):
Relevant Pages
|