pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Temp Tables & Connection Pooling
5+ messages / 4 participants
[nested] [flat]

* Temp Tables & Connection Pooling
@ 2001-03-02 18:40 Gerald Gutierrez <pozix@home.com>
  2001-03-02 20:48 ` Re: Temp Tables & Connection Pooling David Olbersen <dave@slickness.org>
  2001-03-03 15:43 ` Re: Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Gerald Gutierrez @ 2001-03-02 18:40 UTC (permalink / raw)
  To: pgsql-sql


I use PostgreSQL via a connection pooling mechanism, whether it be J2EE or 
PHP. I've been able to achieve good performance this way, and it has been 
good to me.

Recently I wanted to implement Dijkstra's algorithm as a stored procedure, 
and finding that PL/PGSQL cannot return record sets, I thought about using 
a temporary table for the results. If tempoary tables are session-specific, 
however, then wouldn't connection pooling make it unusable since the table 
might "disappear" from one query to the next? What are alternative 
approaches to implementing Dijkstra's algorithm inside the database?

I'd appreciate any insights.


Gerald.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Temp Tables & Connection Pooling
  2001-03-02 18:40 Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
@ 2001-03-02 20:48 ` David Olbersen <dave@slickness.org>
  2001-03-03 15:32   ` Re: Temp Tables & Connection Pooling Richard Huxton <dev@archonet.com>
  1 sibling, 1 reply; 5+ messages in thread

From: David Olbersen @ 2001-03-02 20:48 UTC (permalink / raw)
  To: Gerald Gutierrez <pozix@home.com>; +Cc: pgsql-sql

On Fri, 2 Mar 2001, Gerald Gutierrez wrote:

->Recently I wanted to implement Dijkstra's algorithm as a stored procedure,
->and finding that PL/PGSQL cannot return record sets, I thought about using
->a temporary table for the results. If tempoary tables are session-specific,
->however, then wouldn't connection pooling make it unusable since the table
->might "disappear" from one query to the next? What are alternative
->approaches to implementing Dijkstra's algorithm inside the database?

<newbie>

Wouldn't a VIEW do what you want?

</newbie>

-- Dave




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Temp Tables & Connection Pooling
  2001-03-02 18:40 Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
  2001-03-02 20:48 ` Re: Temp Tables & Connection Pooling David Olbersen <dave@slickness.org>
@ 2001-03-03 15:32   ` Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Richard Huxton @ 2001-03-03 15:32 UTC (permalink / raw)
  To: David Olbersen <dave@slickness.org>; +Cc: Gerald Gutierrez <pozix@home.com>; pgsql-sql

David Olbersen wrote:
> 
> On Fri, 2 Mar 2001, Gerald Gutierrez wrote:
> 
> ->Recently I wanted to implement Dijkstra's algorithm as a stored procedure,
> ->and finding that PL/PGSQL cannot return record sets, I thought about using
> ->a temporary table for the results. If tempoary tables are session-specific,
> ->however, then wouldn't connection pooling make it unusable since the table
> ->might "disappear" from one query to the next? What are alternative
> ->approaches to implementing Dijkstra's algorithm inside the database?
> 
> <newbie>
> Wouldn't a VIEW do what you want?
> </newbie>
> 
> -- Dave

Presumably Gerald's after speed here - IIRC Dijkstra's is shortest path
finder, so probably not cheap.

I was thinking about the temp table problem the other day, and the best
I could come up with involved creating a higher-level connection
(application-level session basically). You'd create a table mytempNNN
(where NNN is a unique number to identify your user's session) and add a
line to a tracking table (NNN,now())

Every time you use mytempNNN update the tracking table's time and run a
separate reaper process to kill anything not used for 15 minutes (or whatever).

You should be able to automate this to a degree with triggers etc.

- Richard Huxton



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Temp Tables & Connection Pooling
  2001-03-02 18:40 Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
@ 2001-03-03 15:43 ` Gerald Gutierrez <pozix@home.com>
  2001-03-03 17:38   ` Re: Temp Tables & Connection Pooling Ian Harding <iharding@pakrat.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Gerald Gutierrez @ 2001-03-03 15:43 UTC (permalink / raw)
  To: David Olbersen <dave@slickness.org>; +Cc: pgsql-sql

At 12:48 PM 3/2/2001 -0800, David Olbersen wrote:
>On Fri, 2 Mar 2001, Gerald Gutierrez wrote:
>
>->Recently I wanted to implement Dijkstra's algorithm as a stored procedure,
>->and finding that PL/PGSQL cannot return record sets, I thought about using
>->a temporary table for the results. If tempoary tables are session-specific,
>->however, then wouldn't connection pooling make it unusable since the table
>->might "disappear" from one query to the next? What are alternative
>->approaches to implementing Dijkstra's algorithm inside the database?
>
><newbie>
>Wouldn't a VIEW do what you want?
></newbie>

No it wouldn't. Executing Dijkstra would involve executing iterative logic 
on multiple tables and storing intermediate results in a form that can be 
returned to the user but does not affect the actual persistent table schema 
(e.g. a record set, or a temporary table). A view is used to provide a 
simplified or alternative way of looking at a set of data, and cannot 
cannot generally multi-step operation that data prior to returning to the user.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Temp Tables & Connection Pooling
  2001-03-02 18:40 Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
  2001-03-03 15:43 ` Re: Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
@ 2001-03-03 17:38   ` Ian Harding <iharding@pakrat.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Ian Harding @ 2001-03-03 17:38 UTC (permalink / raw)
  To: pgsql-sql

Gerald Gutierrez wrote:

> At 12:48 PM 3/2/2001 -0800, David Olbersen wrote:
> >On Fri, 2 Mar 2001, Gerald Gutierrez wrote:
> >
> >->Recently I wanted to implement Dijkstra's algorithm as a stored procedure,
> >->and finding that PL/PGSQL cannot return record sets, I thought about using
> >->a temporary table for the results. If tempoary tables are session-specific,
> >->however, then wouldn't connection pooling make it unusable since the table
> >->might "disappear" from one query to the next? What are alternative
> >->approaches to implementing Dijkstra's algorithm inside the database?
> >
> ><newbie>
> >Wouldn't a VIEW do what you want?
> ></newbie>
>
> No it wouldn't. Executing Dijkstra would involve executing iterative logic
> on multiple tables and storing intermediate results in a form that can be
> returned to the user but does not affect the actual persistent table schema
> (e.g. a record set, or a temporary table). A view is used to provide a
> simplified or alternative way of looking at a set of data, and cannot
> cannot generally multi-step operation that data prior to returning to the user.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

This looks like  a case for a persistent table where the function would write the
data, along with some kind of session identifier, which would be returned from the
function.  Then your could go back to that table with that sessionid and find what
you need.  It is kludgey because it has the potential to leave stale data lying
around, you will have to write all kinds of housekeeping code around it.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2001-03-03 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-02 18:40 Temp Tables & Connection Pooling Gerald Gutierrez <pozix@home.com>
2001-03-02 20:48 ` David Olbersen <dave@slickness.org>
2001-03-03 15:32   ` Richard Huxton <dev@archonet.com>
2001-03-03 15:43 ` Gerald Gutierrez <pozix@home.com>
2001-03-03 17:38   ` Ian Harding <iharding@pakrat.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox