Hello pgsql-general,
I'm trying to implement a table with rows that are automatically
deleted when the session that inserted them disconnects, sort of like
our own alternative to pg_stat_activit y. Is it possible and what
approach should I be trying to achieve such a thing?
Thanks!
--
-Boris
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match 21 3230
Hello Dennis,
Friday, November 7, 2003, 1:29:32 PM, you wrote:
DG> Boris Popov wrote: Hello pgsql-general,
I'm trying to implement a table with rows that are automatically deleted when the session that inserted them disconnects, sort of like our own alternative to pg_stat_activit y. Is it possible and what approach should I be trying to achieve such a thing?
DG> who do you want it visible to? If you don't want it visible to
DG> anybody but the session you are writing them from, just don't
DG> commit them and use the right kind of transaction that allows you
DG> to see them from the session you are in.
I do want them to be visible to everybody. This is a sessions pool,
where sessions are inserted when our app connects and removed when it
disconnects, however this would only work for graceful disconnects,
which we all know isn't always the case. So I want a table that is
somehow notified of a session disconnect and deletes rows created by
that session.
Any ideas?
--
-Boris
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly
If the table doesn't have to be 100% accurate, you could always timestamp
the rows and have connected clients update their row, while old rows get
reaped periodicaly.
On Fri, 7 Nov 2003, Boris Popov wrote: I do want them to be visible to everybody. This is a sessions pool, where sessions are inserted when our app connects and removed when it disconnects, however this would only work for graceful disconnects, which we all know isn't always the case. So I want a table that is somehow notified of a session disconnect and deletes rows created by that session.
Any ideas?
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly
Hello Ben,
Friday, November 7, 2003, 2:53:09 PM, you wrote:
B> If the table doesn't have to be 100% accurate, you could always timestamp
B> the rows and have connected clients update their row, while old rows get
B> reaped periodicaly.
I was hoping for a more natural solution. Implementing a heartbeat in
the application is a complication I'd like to avoid at all cost.
-Boris
B> On Fri, 7 Nov 2003, Boris Popov wrote: I do want them to be visible to everybody. This is a sessions pool, where sessions are inserted when our app connects and removed when it disconnects, however this would only work for graceful disconnects, which we all know isn't always the case. So I want a table that is somehow notified of a session disconnect and deletes rows created by that session.
Any ideas?
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
What you really want is an end of session callback.
There is not one in PostgreSQL. However, if this is
for session management, you can handle this in your
application by bracketing the connection code with
the table management.
That is, in your app (or rather in your session pooling
code) follow up each close with a DELETE of the rows
in question. The only tricky part is deciding on the
key so that it is known both before and after the connection.
Does this make sense?
elein
On Fri, Nov 07, 2003 at 01:09:15PM -0800, Boris Popov wrote: Hello pgsql-general,
I'm trying to implement a table with rows that are automatically deleted when the session that inserted them disconnects, sort of like our own alternative to pg_stat_activit y. Is it possible and what approach should I be trying to achieve such a thing?
Thanks!
-- -Boris ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
I found one way to do by combining temporary table and inhertis.
Temporary table will automatically dropped when disconnects, and
table can show inherited tables result, too.I assume SQL_Inheritance is
on.
Or you can use union too.
ex.
create table a(...);
insert into a(...); # fixed values
create table b() inherits (a);
insert into b values(...); # temporary values
select * from a; # You can get both global and temporary values.
On Fri, 07 Nov 2003 13:09:15 -0800
Boris Popov <bo***@procediu m.com> wrote: Hello pgsql-general,
I'm trying to implement a table with rows that are automatically deleted when the session that inserted them disconnects, sort of like our own alternative to pg_stat_activit y. Is it possible and what approach should I be trying to achieve such a thing?
Thanks!
-- -Boris ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
--
TANIDA Yutaka <ta****@sra.co. jp>
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly
This is great! I have been looking for this too... I think this should go in the manual as an example of how application sessions can be recorded in the db. Very useful!
/M
----- Original Message -----
From: "TANIDA Yutaka" <ta****@sra.co. jp>
To: "Boris Popov" <bo***@procediu m.com>
Cc: <pg***********@ postgresql.org>
Sent: Monday, November 10, 2003 2:41 AM
Subject: Re: [GENERAL] Temp rows - is it possible? I found one way to do by combining temporary table and inhertis. Temporary table will automatically dropped when disconnects, and table can show inherited tables result, too.I assume SQL_Inheritance is on. Or you can use union too. ex. create table a(...); insert into a(...); # fixed values create table b() inherits (a); insert into b values(...); # temporary values select * from a; # You can get both global and temporary values. On Fri, 07 Nov 2003 13:09:15 -0800 Boris Popov <bo***@procediu m.com> wrote: Hello pgsql-general, I'm trying to implement a table with rows that are automatically deleted when the session that inserted them disconnects, sort of like our own alternative to pg_stat_activit y. Is it possible and what approach should I be trying to achieve such a thing? Thanks! -- -Boris ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match -- TANIDA Yutaka <ta****@sra.co. jp> ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to ma*******@postg resql.org so that your message can get through to the mailing list cleanly
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
"Mattias Kregert" <ma*****@kreger t.se> writes: This is great! create table a(...); insert into a(...); # fixed values
create table b() inherits (a); insert into b values(...); # temporary values
select * from a; # You can get both global and temporary values.
I don't think it's actually reliable. B was meant to be a temp table,
right? The problem is that B will be globally visible to all sessions
as being a child table of A, but because temp tables are processed in
backend-local buffers, it will be quite erratic whether other sessions
can see the rows you've inserted. In an experiment just now, another
session could not see the rows in B until I'd inserted several thousand
of them (enough to overrun the local buffers) ... and then the other
session could see some but not all of them.
We recently decided we had to forbid foreign-key references from temp
tables to permanent tables because of this effect. I wonder whether
we won't end up forbidding temp tables as children of permanent tables
too.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Tom Lane wrote: "Mattias Kregert" <ma*****@kreger t.se> writes: This is great!
create table a(...); insert into a(...); # fixed values
create table b() inherits (a); insert into b values(...); # temporary values
select * from a; # You can get both global and temporary values.
I don't think it's actually reliable. B was meant to be a temp table, right? The problem is that B will be globally visible to all sessions as being a child table of A, but because temp tables are processed in backend-local buffers, it will be quite erratic whether other sessions can see the rows you've inserted. In an experiment just now, another session could not see the rows in B until I'd inserted several thousand of them (enough to overrun the local buffers) ... and then the other session could see some but not all of them.
We recently decided we had to forbid foreign-key references from temp tables to permanent tables because of this effect. I wonder whether we won't end up forbidding temp tables as children of permanent tables too.
Yep, I think we will have to do that. TODO item?
--
Bruce Momjian | http://candle.pha.pa.us pg***@candle.ph a.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Bruce Momjian <pg***@candle.p ha.pa.us> writes: Tom Lane wrote: We recently decided we had to forbid foreign-key references from temp tables to permanent tables because of this effect. I wonder whether we won't end up forbidding temp tables as children of permanent tables too.
Yep, I think we will have to do that. TODO item?
Plan B would be to arrange for the planner to ignore temp tables of
other backends whenever it is searching for child tables. Then the
behavior would be predictable: you never see any rows inserted in other
people's temp child tables (and cannot update or delete 'em, either).
I'm not sure if this is the behavior the OP wanted, but it seems at
least marginally useful.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ootyguy |
last post by:
Trying to do this all day and googling for answers but found none, hope
someone can help. Thanks in advance.
select * into
OPENROWSET('SQLOLEDB','SERVER';'uid';'pwd',##test)
from LocalTable
Reason: I am joining local tables with linked server tables using the
format "LinkedServer.database.owner.object" to execute a query, it
takes forever to execute since the tables joined on the remote servers
|
by: Phil Short via DotNetMonster.com |
last post by:
I'm having trouble using a temp table in Oracle. Here's my code:
Dim myConn As OleDbConnection
Dim strconn As String = Session.Item("optSrcDBConnect")
Dim dcSQL As OleDbCommand
Dim strSQL As String
Dim drSQL As OleDbDataReader
WriteLog("Open connection")
|
by: Timothy Perrigo |
last post by:
This bug? feature? caused a bit of havoc for us yesterday...A
reproducible example follows. Essentially, if you have a table with a
primary key called "id", and you create a temp table (via a "select
into") containing a subset of the data from the table but where the
primary key field is renamed (in the example below, it is called
"not_id"), the where clause of the following update statement (which I
would expect to generate an error...
|
by: wackyphill |
last post by:
If you were doing paging of results on a web page and were interested
in grabbing say records 10-20 of a result set. But also wanted to know
the total # of records in the result set (so you could know the total #
of pages in the set).
Would it be better to query the DB table 2X. Once for Count(*). And
again for the records for the current page?
Or better to create a temp table, select the records into it, and then
get count(*) and the...
|
by: fmatamoros |
last post by:
I sometimes get the following error from an update statement in a
stored procedure:
Transaction (Process ID 62) was deadlocked on thread | communication
buffer resources with another process and has been chosen as the
deadlock victim. Rerun the transaction.
The isolation level is READ UNCOMMITTED and there are no explicit
transactions in the stored procedure. The update statement is as
follows:
| |
by: robert d via AccessMonster.com |
last post by:
When my app starts up, it creates a temporary database. This temp database
is created from a 'model' database that is in the same folder as the
application. Because there is a model, the creation is essentially to just
copy the 'model' database and give it the name of the application with the
extension ".tmp".
Then code opens the temp database and links to the tables. This has always
worked flawlessly until today. Today, I needed to...
|
by: Burbletrack |
last post by:
Hi All,
Hope someone can help me...
Im trying to highlight the advantages of using table variables as
apposed to temp tables within single scope.
My manager seems to believe that table variables are not advantageous
because they reside in memory.
He also seems to believe that temp tables do not use memory...
|
by: Arun Srinivasan |
last post by:
I have a sql that goes like
select ............... from table (select ....... from table t where
<>) as x
Now this temp table x is supposed to keep 10 K rows at a point of
time. Where would they be stored? I know the answer is temp
tablespace, but is it in system temp or user temp?
All I am trying to do is to create a temp (sys or user) with good
amount of pages so that these kinds of queries would speed up. I dont
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |