Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 06:54 PM
Mike
 
Posts: n/a
Default Urgent Questions regarding Index usage & VIEWs, sorting, etc.

Hello,

I have a few rather urgent questions that I hope someone can help with (I
need to figure this out prior to a meeting tomorrow.) First, a bit of
background: The company I work for is developing a web-based application,
one part of which involves allowing the user the ability to page through
transaction "history" information.

The _summary_ history table will have the following fields: ServiceName,
Date, User-Ref1, User-Ref2, User-Ref3, TransactionID. The "User-Ref" fields
are supplied by the user to help them identify records of interest.

The user will be allowed to choose from several different, pre-defined sort
orders. For example, the default sort order might be: Date, ServiceName,
User-Ref1, User-Ref2, User-Ref3, TransactionID. The user can click on the
headings "Date", "ServiceName", and "User-Ref1", to make those columns,
respectively, the primary sort column. So, if they click on "ServiceName",
then the pre-defined sort order would be: ServiceName, Date, User-Ref1,
User-Ref2, User-Ref3, TransactionID. If they click on "User-Ref1", then the
pre-defined sort order would be: User-Ref1, Date, ServiceName, User-Ref2,
User-Ref3, TransactionID. (That may not be exactly right, but the main
point is that the sort orders the user can choose from are pre-defined,
based on the primary sort column - they can't change the order of the other
columns.)

The other item of importance is that the user needs to be able to page
through the data. We're planning on using an identity column on the table
in support of this - i.e., to pick up from where the last UID left off.

Finally, the user will be allowed to subset the data by date range.

Okay, here goes my questions:

Regarding VIEWs
------------------

1. One of my questions relates to the use of VIEWs. I was thinking that, in
order to make the stored procedure logic more concise, that we could create
a separate VIEW for each sort order. However, someone said that VIEWs
involve the use of dynamic SQL that must be prepared each time by DB/2. Is
that correct? I would think that, since the query that represents the VIEW
doesn't change, it would be static.

2. The same person also said that VIEWs are used to subset data (i.e., with
a WHERE clause), not for simple ordering. Is that correct? Again, my
thinking was to create a VIEW for each sort order - i.e., a SELECT with a
different ORDER BY for each VIEW.

Basically, I figured that if we used VIEWs for the sorting, then the actual
stored procedure code would be identical for each query (it would just
specify a different VIEW name for each.)



Regarding Indexes
-------------------

3. It was also stated that any indexes on the table would only be used by
the WHERE clause, not by the ORDER BY clause. Is that right? I was
thinking that we would need an index for the subsetting (date range) WHERE
clause, plus indexes for each pre-defined sort order (or at least the most
popular sort orders.) But it was implied that you can't do this.



Regarding Limiting the Result Set Size
--------------------------------------

4. The front-end web application has memory constraints, and so can only
handle a certain maximum number of rows in a result set. I was thinking
that we could use the "FETCH x ROWS ONLY" clause to limit the size of the
result set, and also limit the processing that DB/2 has to perform.
However, I was told that DB/2 would still need to process the entire result
set, and that "further constraints" would be necessary. Is that correct?
In particular, it was stated that if a sort (ORDERY BY) is involved, then
DB/2 builds the complete result set after processing all qualifying (WHERE)
records. So, basically, if I have a SELECT with both WHERE and ORDER BY,
will FETCH x ROWS ONLY limit the amount of work that DB/2 has to perform or
not?


Thank you VERY MUCH for any help with these questions! If possible and
convenient, it would be great if you could also e-mail any responses to my
address below (please remove NOSPAM from the address.)

Regards,

Mike
mmills1969@NOSPAMyahoo.com




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 06:54 PM
Ian
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

Mike wrote:
> Hello,
>
> I have a few rather urgent questions that I hope someone can help with (I
> need to figure this out prior to a meeting tomorrow.) First, a bit of
> background: The company I work for is developing a web-based application,
> one part of which involves allowing the user the ability to page through
> transaction "history" information.


You don't say which platform DB2 is running on, so I will assume Linux,
UNIX or Windows.

>
> The other item of importance is that the user needs to be able to page
> through the data. We're planning on using an identity column on the table
> in support of this - i.e., to pick up from where the last UID left off.


You should probably search in this newsgroup (and in the DB2 UDB SQL
reference) for OLAP functions like rownumber().

This has been talked about extensively in this group with regard to
fetching "pages" of data at a time.


>
> Regarding VIEWs
> ------------------
>
> 1. One of my questions relates to the use of VIEWs. I was thinking that, in
> order to make the stored procedure logic more concise, that we could create
> a separate VIEW for each sort order. However, someone said that VIEWs
> involve the use of dynamic SQL that must be prepared each time by DB/2. Is
> that correct? I would think that, since the query that represents the VIEW
> doesn't change, it would be static.


Views don't have anything to do with static/dynamic SQL. Static/Dynamic
defines when the access path is chosen -- either at build time (static)
or run-time (dynamic).

> 2. The same person also said that VIEWs are used to subset data (i.e., with
> a WHERE clause), not for simple ordering. Is that correct? Again, my
> thinking was to create a VIEW for each sort order - i.e., a SELECT with a
> different ORDER BY for each VIEW.


Views represent an unordered set of data (i.e., just like a table). You
can't specify an order-by in the view definition.

> Regarding Indexes
> -------------------
>
> 3. It was also stated that any indexes on the table would only be used by
> the WHERE clause, not by the ORDER BY clause. Is that right? I was
> thinking that we would need an index for the subsetting (date range) WHERE
> clause, plus indexes for each pre-defined sort order (or at least the most
> popular sort orders.) But it was implied that you can't do this.


Indexes may or may not be used for predicates (where clause) or sorting.
Indexes on columns referenced in the predicate are (in my book) much
more important (and more likely to be used).

The SQL compiler will make the decision on which index(es) to use based
on filter factors on the predicates, cardinality of the table(s),
columns in the query, etc.

> Regarding Limiting the Result Set Size
> --------------------------------------
>
> 4. The front-end web application has memory constraints, and so can only
> handle a certain maximum number of rows in a result set. I was thinking
> that we could use the "FETCH x ROWS ONLY" clause to limit the size of the
> result set, and also limit the processing that DB/2 has to perform.
> However, I was told that DB/2 would still need to process the entire result
> set, and that "further constraints" would be necessary. Is that correct?
> In particular, it was stated that if a sort (ORDERY BY) is involved, then
> DB/2 builds the complete result set after processing all qualifying (WHERE)
> records. So, basically, if I have a SELECT with both WHERE and ORDER BY,
> will FETCH x ROWS ONLY limit the amount of work that DB/2 has to perform or
> not?


Unless your application is doing something strange (like trying to store
the entire result set in memory on the client), the memory usage will be
primarily on the database server, not on the client, regardless of the
size of your result set. There are communication buffers between the
server and client that control how much data is transferred / buffered,
but this shouldn't be a big deal (the default is 32kb).


Good luck,



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 06:54 PM
Rhino
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.


"Mike" <mwmills1969@NOSPAMyahoo.com> wrote in message
news:yqmdneu7OaecRW_d4p2dnA@giganews.com...
> Hello,
>
> I have a few rather urgent questions that I hope someone can help with (I
> need to figure this out prior to a meeting tomorrow.)


It's probably not a good idea to leave urgent questions to the last minute
and then insist that they are urgent....

> First, a bit of
> background: The company I work for is developing a web-based application,
> one part of which involves allowing the user the ability to page through
> transaction "history" information.
>
> The _summary_ history table will have the following fields: ServiceName,
> Date, User-Ref1, User-Ref2, User-Ref3, TransactionID. The "User-Ref"

fields
> are supplied by the user to help them identify records of interest.
>
> The user will be allowed to choose from several different, pre-defined

sort
> orders. For example, the default sort order might be: Date, ServiceName,
> User-Ref1, User-Ref2, User-Ref3, TransactionID. The user can click on the
> headings "Date", "ServiceName", and "User-Ref1", to make those columns,
> respectively, the primary sort column. So, if they click on

"ServiceName",
> then the pre-defined sort order would be: ServiceName, Date, User-Ref1,
> User-Ref2, User-Ref3, TransactionID. If they click on "User-Ref1", then

the
> pre-defined sort order would be: User-Ref1, Date, ServiceName, User-Ref2,
> User-Ref3, TransactionID. (That may not be exactly right, but the main
> point is that the sort orders the user can choose from are pre-defined,
> based on the primary sort column - they can't change the order of the

other
> columns.)
>
> The other item of importance is that the user needs to be able to page
> through the data. We're planning on using an identity column on the table
> in support of this - i.e., to pick up from where the last UID left off.
>
> Finally, the user will be allowed to subset the data by date range.
>

You haven't told us what platform you are on and what version of DB2 you are
using. This makes it rather difficult to answer your question since each
platform and version can be different in some particulars. For example,
ORDER BY is not permitted in a view definition in DB2 V7.2 for Windows,
Linux, and Unix. ORDER BY may or may not be allowed in view definitions for
other platforms and versions.

> Okay, here goes my questions:
>
> Regarding VIEWs
> ------------------
>
> 1. One of my questions relates to the use of VIEWs. I was thinking that,

in
> order to make the stored procedure logic more concise, that we could

create
> a separate VIEW for each sort order. However, someone said that VIEWs
> involve the use of dynamic SQL that must be prepared each time by DB/2.

Is
> that correct? I would think that, since the query that represents the

VIEW
> doesn't change, it would be static.
>

NOTE: the product we are discussing on this newsgroup is DB2, not DB/2. DB2
is IBM's flagship relational database. If you are actually asking about
DBASE II, which some people abbreviate 'DB/2', you should disregard any
answers you get on this newsgroup because they are almost certainly not
applicable to you.

Your first question is probably moot since I believe that all or at least
most of the recent versions of DB2 don't permit ORDER BY in a view
definition. As noted above though, some platforms and versions may permit
this so you should check CREATE VIEW in the SQL Reference for your
particular platform and version to be sure.

> 2. The same person also said that VIEWs are used to subset data (i.e.,

with
> a WHERE clause), not for simple ordering. Is that correct? Again, my
> thinking was to create a VIEW for each sort order - i.e., a SELECT with a
> different ORDER BY for each VIEW.
>

Views are used for two primary reasons: to provide a subset of rows and
columns of a table or a join of tables and to give you more granular control
over security.

> Basically, I figured that if we used VIEWs for the sorting, then the

actual
> stored procedure code would be identical for each query (it would just
> specify a different VIEW name for each.)
>

As noted above, views will not help you by providing alternate sort orders
for your data unless you happen to be using a DB2 version and platform that
supports ORDER BY in a view definition. I'm not sure if there is such a
version and platform; I have used DB2 on most platforms at one point or
another but in some cases, like DB2 on AS/400 or z/OS, I haven't used the
current versions.
>
> Regarding Indexes
> -------------------
>
> 3. It was also stated that any indexes on the table would only be used by
> the WHERE clause, not by the ORDER BY clause. Is that right? I was
> thinking that we would need an index for the subsetting (date range) WHERE
> clause, plus indexes for each pre-defined sort order (or at least the most
> popular sort orders.) But it was implied that you can't do this.
>

It is not true that the WHERE clause is the only clause that can use an
index. ORDER BY can also use an index. (I think GROUP BY can use indexes too
in some cases, although I'm not sure.)

You can create indexes for each sort order if you like but bear in mind that
DB2 never has to use any given index (or any index at all) for an access
path; it is always DB2's choice. It's the old "you can lead a horse to water
but you can't make him drink" thing: you can create any number of indexes
but DB2 can decline to use these indexes. So don't be angry if you create an
index but DB2 doesn't use it.

There are two main reasons for DB2 declining to use an index: the query will
not benefit from the index (in DB2's estimation) or your SQL is poorly
written.
>
> Regarding Limiting the Result Set Size
> --------------------------------------
>
> 4. The front-end web application has memory constraints, and so can only
> handle a certain maximum number of rows in a result set. I was thinking
> that we could use the "FETCH x ROWS ONLY" clause to limit the size of the
> result set, and also limit the processing that DB/2 has to perform.
> However, I was told that DB/2 would still need to process the entire

result
> set, and that "further constraints" would be necessary. Is that correct?
> In particular, it was stated that if a sort (ORDERY BY) is involved, then
> DB/2 builds the complete result set after processing all qualifying

(WHERE)
> records. So, basically, if I have a SELECT with both WHERE and ORDER BY,
> will FETCH x ROWS ONLY limit the amount of work that DB/2 has to perform

or
> not?
>

I haven't done this sort of programming for a while so my memory on this
point is fuzzy and possibly out-of-date so take what I say with a grain of
salt; maybe someone who is current can confirm or correct what I'm saying on
this point.

Essentially, your friend told you the truth: FETCH x ROWS ONLY does not
limit the size of the result set; it is primarily a hint to the optimizer
that you want the first 'x' rows of the result as quickly as possible. If
possible, DB2 will try to do some "tricks" to get you those rows a little
faster than it otherwise would but there is no guarantee it will be
successful. Also, even if it is successful, if you then go on to read more
rows than the 'x' which you specified, the additional rows may come back
slower than they otherwise would have. FETCH x ROWS ONLY is intended
primarily for an application that will do paging of large result sets and
would mostly be used where the result might be very large while most users
would normally only want 'x' of the rows. If you have an application which
has to page through a lot of rows and you actually expect users to look at
most of those rows most of the time, FETCH x ROWS ONLY probably won't help
you.

If you need to page both forwards and backwards within a result set that is
(potentially) many pages in size, the technique for doing so tends to depend
on the language you are using. For instance, if you use a relatively recent
version of Java and JDBC, you can use scrollable cursors to move backwards
and forwards fairly easily. I just did a very superficial look through the
DB2 V7.2 Application Development manual trying to find a detailed
explanation of paging techniques for each language and didn't find one but I
know the IBM DB2 courses used to explain this technique so there may be
another manual somewhere that explains this. If you can't find anything like
that, post here again and perhaps someone can give you an example that
illustrates the technique for your language and platform.

>
> Thank you VERY MUCH for any help with these questions! If possible and
> convenient, it would be great if you could also e-mail any responses to my
> address below (please remove NOSPAM from the address.)
>

Posted and emailed.

Rhino


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 06:54 PM
Mike
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

Just a follow-up to answer some questions others have raised:

1. The DB2 (sorry, not "DB/2") platform in question is v7 (soon v8), running
on z/OS.
2. The front-end will be written in Java. The stored procedures will
probably be written in COBOL.
3. Regarding the use of cursors for paging: AFAIK, this would require
keeping one connection allocated to each user. We have to plan for high
concurrency, and so this would not be acceptable. (Yes, we will of course
pool the database connections.)
4. Regarding result set size: Two objectives here: 1) Minimize the number
of rows that gets sent to the front-end in any single query (so that we
don't tax memory constraints on the front-end), and 2) Minimize the number
of rows that DB2 has to process (if the front-end can only handle, say, 100
rows, then we would like for DB2 to stop processing the result set after 100
rows - if possible).
5. Regarding Rhino's comments about FETCH FIRST x ROWS ONLY being a 'hint' -
actually, that sounds like like you are talking about the OPTIMIZE FOR x
ROWS clause. According to the SQL Reference manual, FETCH FIRST x ROWS ONLY
can save work for DB2 - but I'm not sure under what circumstances, and if
those apply in my case.
6. Regarding "waiting to the last minute" - I haven't done that. I can't
help that this was discussed at a meeting just today! My intention is to be
well-prepared for tomorrow's meeting.

Let me know if there are any other questions. Your comments are
appreciated!

Regards,

Mike


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-26-2008, 06:55 PM
Anton Versteeg
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

It depends if an index is used or not with an ORDER BY.
When there are fields in your select that are not part of the index,
DB2 might decide a table scan is better so it can do sequential
prefetch. Specially if the index sequence is not the same as the
physical row sequence, retrieving rows via the index might be much more
expensive than retrieving them sequentially. It also depends on the size
of your table of course.

Mike wrote:
> Regarding Indexes
> -------------------
>
> 3. It was also stated that any indexes on the table would only be used by
> the WHERE clause, not by the ORDER BY clause. Is that right? I was
> thinking that we would need an index for the subsetting (date range) WHERE
> clause, plus indexes for each pre-defined sort order (or at least the most
> popular sort orders.) But it was implied that you can't do this.
>


> Regards,
>
> Mike
> mmills1969@NOSPAMyahoo.com


--
Anton Versteeg
IBM Certified DB2 Specialist
IBM Netherlands

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 06:55 PM
Buck Nuggets
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

"Mike" <mwmills1969@NOSPAMyahoo.com> wrote in message news:<c7WdnTEJT8Xkh27dRVn-vA@giganews.com>...

> 3. Regarding the use of cursors for paging: AFAIK, this would require
> keeping one connection allocated to each user. We have to plan for high
> concurrency, and so this would not be acceptable. (Yes, we will of course
> pool the database connections.)
>
> 4. Regarding result set size: Two objectives here: 1) Minimize the number
> of rows that gets sent to the front-end in any single query (so that we
> don't tax memory constraints on the front-end), and 2) Minimize the number
> of rows that DB2 has to process (if the front-end can only handle, say, 100
> rows, then we would like for DB2 to stop processing the result set after 100
> rows - if possible).


Your solutions are pretty restricted if you want separate connections
for each paging query: either you only have one sorting order, or you
cut separate tables each period (day, hour, whatever) that have
separate orders & separate ids in each pre-calculated.

However, if you do keep the single connection for this activity, you
do have other options than a cursor: you can also toss the result set
into a temporary table and use an identity or row_number to populate a
field used for paging. Whether or not that works better than using
row_number() on the original table would depending on factors such as
whether or not you can use an index or have to do a page scan of the
original table, how many next page queries are likely to occur, etc.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-26-2008, 06:55 PM
Mike
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

Thanks for the info. Just to add a bit more info, here is what I'm thinking
the query would look like - note that my original idea was to use a VIEW for
each different ORDERY BY clause, but since that doesn't appear to be
possible, this is how I believe it will look:


Page *Forward* Through Transaction History Summary - Sort Seq #1
-----------------------------------------------------------------------
SELECT * FROM TRANHIST
WHERE UID > :startUID AND
DATE >= :startDate AND
DATE <= :endDate
ORDER BY UID ASC, DATE DESC, SERVICENAME ASC, USERREF1 ASC,
USERREF2 ASC, USERREF3 ASC, TRANID ASC
FETCH FIRST 200 ROWS ONLY;


Page *Backward* Through Transaction History Summary - Sort Seq #1
-------------------------------------------------------------------------
SELECT * FROM TRANHIST
WHERE UID < :startUID AND
DATE >= :startDate AND
DATE <= :endDate
ORDER BY UID DESC, DATE DESC, SERVICENAME ASC, USERREF1 ASC,
USERREF2 ASC, USERREF3 ASC, TRANID ASC
FETCH FIRST 200 ROWS ONLY;


There would then be similar queries for paging forward & backward through
the history, but with different ORDER BY clauses. There would be about 3 or
4 basic sort orders (such as SERVICENAME first, or USERREF1 first), and for
each one of these the user will have the ability to select ASCENDING or
DESCENDING sort order on the *primary* sort column (not the subordinate
columns; those will be pre-defined.) Note that the WHERE clause only
includes the DATE and UID fields.

Anyway, as I mentioned before, one key question is whether the FETCH FIRST x
ROWS ONLY will save DB2 from doing extraneous work or not - i.e., will it
"short-circuit" the query at 200 rows, or will it have to process the entire
result set first? And if it won't save any extra work, is there anything
else I can do to help it?

Again, due to volume & concurrency, we want to save memory utilization on
the front-end, as well as the amount of work DB2 has to do on the back-end.
If the front-end can only cache 200 rows at a time, I'd like to prevent DB2
from having to process more than that, if possible.

Thanks,

Mike



"Anton Versteeg" <anton_versteeg@nnll.ibm.com> wrote in message
news:cd06ej$1270$1@sp15en20.hursley.ibm.com...
> It depends if an index is used or not with an ORDER BY.
> When there are fields in your select that are not part of the index,
> DB2 might decide a table scan is better so it can do sequential
> prefetch. Specially if the index sequence is not the same as the
> physical row sequence, retrieving rows via the index might be much more
> expensive than retrieving them sequentially. It also depends on the size
> of your table of course.
>
> Mike wrote:
> > Regarding Indexes
> > -------------------
> >
> > 3. It was also stated that any indexes on the table would only be used

by
> > the WHERE clause, not by the ORDER BY clause. Is that right? I was
> > thinking that we would need an index for the subsetting (date range)

WHERE
> > clause, plus indexes for each pre-defined sort order (or at least the

most
> > popular sort orders.) But it was implied that you can't do this.
> >

>
> > Regards,
> >
> > Mike
> > mmills1969@NOSPAMyahoo.com

>
> --
> Anton Versteeg
> IBM Certified DB2 Specialist
> IBM Netherlands
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-26-2008, 06:55 PM
Mike
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.


"Buck Nuggets" <bucknuggets@yahoo.com> wrote in message
news:66a61715.0407130749.356ddb81@posting.google.c om...
> "Mike" <mwmills1969@NOSPAMyahoo.com> wrote in message

news:<c7WdnTEJT8Xkh27dRVn-vA@giganews.com>...
>
> > 3. Regarding the use of cursors for paging: AFAIK, this would require
> > keeping one connection allocated to each user. We have to plan for high
> > concurrency, and so this would not be acceptable. (Yes, we will of

course
> > pool the database connections.)
> >
> > 4. Regarding result set size: Two objectives here: 1) Minimize the

number
> > of rows that gets sent to the front-end in any single query (so that we
> > don't tax memory constraints on the front-end), and 2) Minimize the

number
> > of rows that DB2 has to process (if the front-end can only handle, say,

100
> > rows, then we would like for DB2 to stop processing the result set after

100
> > rows - if possible).

>
> Your solutions are pretty restricted if you want separate connections
> for each paging query: either you only have one sorting order, or you
> cut separate tables each period (day, hour, whatever) that have
> separate orders & separate ids in each pre-calculated.


Thanks for the comments. But, do you agree that if high concurrency is a
concern, that we can't really allocate a connection to a single user, while
the user "thinks" about paging forward/backward?

About the temporary table - wouldn't that be on a per-connection basis,
though? Or could I access the same temporary table from *any* connection?
(Of course I realize that I could optimize the connection pool such that the
front-end will *try* to re-use the same connection, if available - but I
don't want to count on this.)

Thanks,

Mike


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-26-2008, 06:55 PM
Buck Nuggets
 
Posts: n/a
Default Re: Urgent Questions regarding Index usage & VIEWs, sorting, etc.

"Mike" <mwmills1969@NOSPAMyahoo.com> wrote in message news:<LfidnTjWAt8KiWndRVn-hw@giganews.com>...

> Thanks for the comments. But, do you agree that if high concurrency is a
> concern, that we can't really allocate a connection to a single user, while
> the user "thinks" about paging forward/backward?


sure, i can see how this would be a concern.

> About the temporary table - wouldn't that be on a per-connection basis,
> though? Or could I access the same temporary table from *any* connection?
> (Of course I realize that I could optimize the connection pool such that the
> front-end will *try* to re-use the same connection, if available - but I
> don't want to count on this.)


no, you can't share it across connections. however, there are still
quite a few other, similar options: create a permanent table instead.
You'd have to figure out when to asyncronously drop it, it's slower to
create, and you'd have to figure out what to name it, but it could
work the same way as the temp table otherwise.

Still, perhaps the first query retrieval time would be expensive. Not
sure about what kind of insertion rate you're looking at, or what the
model looks like (unique key?), but...have you considered using
something like multiple MQTs with ids representing various sort
orders? Would be impossible to keep perfectly up to date (update
hourly?), but would be very fast on retrieval since you could easily
rely on an index to grab a small number of rows at a time...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:05 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346