pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Mail about duplicate rows
6+ messages / 3 participants
[nested] [flat]

* Mail about duplicate rows
@ 1999-06-07 02:33 Vikrant Rathore <vikrant@chemquick.com>
  1999-06-07 05:11 ` Re: [SQL] Mail about duplicate rows Fomichev Michael <fomichev@null.ru>
  0 siblings, 1 reply; 6+ messages in thread

From: Vikrant Rathore @ 1999-06-07 02:33 UTC (permalink / raw)
  To: pgsql-sql@hub.org

I am trying to append a table radius from another table radiustemp, both
having the same structure, but want to append only those tuples from
radiustemp which are not there in radius. The size of the table can be
up to 165 MB.
So anyone can suggest me a better way of doing this.

The structure if table is like this .

Table    = radius
+----------------------------------+----------------------------------+-------+

|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+

| uname                            | char()
|   256 |
| logdate                          | date
|     4 |
| logtime                          | time
|     8 |
| duration                         | int4
|     4 |
| status                           | char()
|    20 |
| nasadd                           | char()
|    20 |
| port                             | int4
|     4 |
| bytesin                          | int4
|     4 |
| bytesout                         | int4
|     4 |
| packin                           | int4
|     4 |
| packout                          | int4
|     4 |
| misc                             | int4
|     4 |
+----------------------------------+----------------------------------+-------+

Thank's in advance for your help.

Thanks & regards,
Vicky




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

* Re: [SQL] Mail about duplicate rows
  1999-06-07 02:33 Mail about duplicate rows Vikrant Rathore <vikrant@chemquick.com>
@ 1999-06-07 05:11 ` Fomichev Michael <fomichev@null.ru>
  1999-06-07 05:37   ` Re: [SQL] Mail about duplicate rows Vikrant Rathore <vikrant@chemquick.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Fomichev Michael @ 1999-06-07 05:11 UTC (permalink / raw)
  To: pgsql-sql@postgresql.org, Vikrant Rathore <vikrant@chemquick.com>



On Mon, 7 Jun 1999, Vikrant Rathore wrote:

> I am trying to append a table radius from another table radiustemp, both
> having the same structure, but want to append only those tuples from
> radiustemp which are not there in radius. The size of the table can be
> up to 165 MB.
> So anyone can suggest me a better way of doing this.
> 
> The structure if table is like this .
> 
> Table    = radius
> +----------------------------------+----------------------------------+-------+
> 
> |              Field               |              Type                |
> Length|
> +----------------------------------+----------------------------------+-------+
> 
> | uname                            | char()
> |   256 |
> | logdate                          | date
> |     4 |
> | logtime                          | time
> |     8 |
> | duration                         | int4
> |     4 |
> | status                           | char()
> |    20 |
> | nasadd                           | char()
> |    20 |
> | port                             | int4
> |     4 |
> | bytesin                          | int4
> |     4 |
> | bytesout                         | int4
> |     4 |
> | packin                           | int4
> |     4 |
> | packout                          | int4
> |     4 |
> | misc                             | int4
> |     4 |
> +----------------------------------+----------------------------------+-------+
> 
> Thank's in advance for your help.
> 
> Thanks & regards,
> Vicky
> 
insert into RADIUS select * from RADIUSTEMP where UNAME not in (select
UNAME from RADIUS)

UNAME must be unique. If it is not, than you need to use another field
(for example "code") which will be unique.

P.S. Nice book about SQL: "Understanding SQL" by Martin Gruber. ISBN
5-85582-010-6

@------------------+-----------------------------------------------@
| Fomichev Mikhail | The Government of Kamchatka region.           |
| Vladimirovich    | The Labour and Social Development Department. |
|<fomichev@null.ru>|                                               |
@------------------+-----------------------------------------------@





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

* Re: [SQL] Mail about duplicate rows
  1999-06-07 02:33 Mail about duplicate rows Vikrant Rathore <vikrant@chemquick.com>
  1999-06-07 05:11 ` Re: [SQL] Mail about duplicate rows Fomichev Michael <fomichev@null.ru>
@ 1999-06-07 05:37   ` Vikrant Rathore <vikrant@chemquick.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Vikrant Rathore @ 1999-06-07 05:37 UTC (permalink / raw)
  To: Fomichev Michael <fomichev@null.ru>; +Cc: pgsql-sql

Thanks for your help. But as you know the UNAME is not unique in radius logs. The
primary key for this table is (Uname,logdate,logtime).

So this three fields together forms a primary key of the table.

Thanks & regards,
Vicky


Fomichev Michael wrote:

> On Mon, 7 Jun 1999, Vikrant Rathore wrote:
>
> > I am trying to append a table radius from another table radiustemp, both
> > having the same structure, but want to append only those tuples from
> > radiustemp which are not there in radius. The size of the table can be
> > up to 165 MB.
> > So anyone can suggest me a better way of doing this.
> >
> > The structure if table is like this .
> >
> > Table    = radius
> > +----------------------------------+----------------------------------+-------+
> >
> > |              Field               |              Type                |
> > Length|
> > +----------------------------------+----------------------------------+-------+
> >
> > | uname                            | char()
> > |   256 |
> > | logdate                          | date
> > |     4 |
> > | logtime                          | time
> > |     8 |
> > | duration                         | int4
> > |     4 |
> > | status                           | char()
> > |    20 |
> > | nasadd                           | char()
> > |    20 |
> > | port                             | int4
> > |     4 |
> > | bytesin                          | int4
> > |     4 |
> > | bytesout                         | int4
> > |     4 |
> > | packin                           | int4
> > |     4 |
> > | packout                          | int4
> > |     4 |
> > | misc                             | int4
> > |     4 |
> > +----------------------------------+----------------------------------+-------+
> >
> > Thank's in advance for your help.
> >
> > Thanks & regards,
> > Vicky
> >
> insert into RADIUS select * from RADIUSTEMP where UNAME not in (select
> UNAME from RADIUS)
>
> UNAME must be unique. If it is not, than you need to use another field
> (for example "code") which will be unique.
>
> P.S. Nice book about SQL: "Understanding SQL" by Martin Gruber. ISBN
> 5-85582-010-6
>
> @------------------+-----------------------------------------------@
> | Fomichev Mikhail | The Government of Kamchatka region.           |
> | Vladimirovich    | The Labour and Social Development Department. |
> |<fomichev@null.ru>|                                               |
> @------------------+-----------------------------------------------@




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

* RE: [SQL] Mail about duplicate rows
@ 1999-06-07 21:37 Jackson, DeJuan <djackson@cpsgroup.com>
  1999-06-08 02:52 ` Re: [SQL] Mail about duplicate rows Vikrant Rathore <vikrant@chemquick.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Jackson, DeJuan @ 1999-06-07 21:37 UTC (permalink / raw)
  To: vikrant@chemquick.com, Fomichev Michael <fomichev@null.ru>; +Cc: pgsql-sql

Then you would use:
INSERT INTO radius
SELECT * FROM raduistemp r1
WHERE NOT EXISTS(SELECT 1 FROM radius r2
    WHERE r1.uname=r2.uname AND r1.logdate=r2.logdate AND
r1.logtime=r2.logtime);
	-DEJ

> -----Original Message-----
> From:	Vikrant Rathore [SMTP:vikrant@chemquick.com]
> Sent:	Monday, June 07, 1999 12:37 AM
> To:	Fomichev Michael
> Cc:	pgsql-sql@postgreSQL.org
> Subject:	Re: [SQL] Mail about duplicate rows
> 
> Thanks for your help. But as you know the UNAME is not unique in radius
> logs. The
> primary key for this table is (Uname,logdate,logtime).
> 
> So this three fields together forms a primary key of the table.
> 
> Thanks & regards,
> Vicky
> 
> 
> Fomichev Michael wrote:
> 
> > On Mon, 7 Jun 1999, Vikrant Rathore wrote:
> >
> > > I am trying to append a table radius from another table radiustemp,
> both
> > > having the same structure, but want to append only those tuples from
> > > radiustemp which are not there in radius. The size of the table can be
> > > up to 165 MB.
> > > So anyone can suggest me a better way of doing this.
> > >
> > > The structure if table is like this .
> > >
> > > Table    = radius
> > >
> +----------------------------------+----------------------------------+---
> ----+
> > >
> > > |              Field               |              Type
> |
> > > Length|
> > >
> +----------------------------------+----------------------------------+---
> ----+
> > >
> > > | uname                            | char()
> > > |   256 |
> > > | logdate                          | date
> > > |     4 |
> > > | logtime                          | time
> > > |     8 |
> > > | duration                         | int4
> > > |     4 |
> > > | status                           | char()
> > > |    20 |
> > > | nasadd                           | char()
> > > |    20 |
> > > | port                             | int4
> > > |     4 |
> > > | bytesin                          | int4
> > > |     4 |
> > > | bytesout                         | int4
> > > |     4 |
> > > | packin                           | int4
> > > |     4 |
> > > | packout                          | int4
> > > |     4 |
> > > | misc                             | int4
> > > |     4 |
> > >
> +----------------------------------+----------------------------------+---
> ----+
> > >
> > > Thank's in advance for your help.
> > >
> > > Thanks & regards,
> > > Vicky
> > >
> > insert into RADIUS select * from RADIUSTEMP where UNAME not in (select
> > UNAME from RADIUS)
> >
> > UNAME must be unique. If it is not, than you need to use another field
> > (for example "code") which will be unique.
> >
> > P.S. Nice book about SQL: "Understanding SQL" by Martin Gruber. ISBN
> > 5-85582-010-6
> >
> > @------------------+-----------------------------------------------@
> > | Fomichev Mikhail | The Government of Kamchatka region.           |
> > | Vladimirovich    | The Labour and Social Development Department. |
> > |<fomichev@null.ru>|                                               |
> > @------------------+-----------------------------------------------@
> 



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

* Re: [SQL] Mail about duplicate rows
  1999-06-07 21:37 RE: [SQL] Mail about duplicate rows Jackson, DeJuan <djackson@cpsgroup.com>
@ 1999-06-08 02:52 ` Vikrant Rathore <vikrant@chemquick.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Vikrant Rathore @ 1999-06-08 02:52 UTC (permalink / raw)
  To: Jackson, DeJuan <djackson@cpsgroup.com>; +Cc: Fomichev Michael <fomichev@null.ru>; pgsql-sql

Dear Jackson and Michael,

    Thanks very much for your help the query worked. Also can you help in one
more way. It took a lot of time to update the radius table around 5 minutes, the
size of the table was around 360 KB's only, so could you suggest a way of
improving the performance since if i am having a table of around 120 - 165 MB it
does not take much time to update the radius table.

Thanks for your help once again.

Regards,
Vicky


"Jackson, DeJuan" wrote:

> Then you would use:
> INSERT INTO radius
> SELECT * FROM raduistemp r1
> WHERE NOT EXISTS(SELECT 1 FROM radius r2
>     WHERE r1.uname=r2.uname AND r1.logdate=r2.logdate AND
> r1.logtime=r2.logtime);
>         -DEJ
>
> > -----Original Message-----
> > From: Vikrant Rathore [SMTP:vikrant@chemquick.com]
> > Sent: Monday, June 07, 1999 12:37 AM
> > To:   Fomichev Michael
> > Cc:   pgsql-sql@postgreSQL.org
> > Subject:      Re: [SQL] Mail about duplicate rows
> >
> > Thanks for your help. But as you know the UNAME is not unique in radius
> > logs. The
> > primary key for this table is (Uname,logdate,logtime).
> >
> > So this three fields together forms a primary key of the table.
> >
> > Thanks & regards,
> > Vicky
> >
> >
> > Fomichev Michael wrote:
> >
> > > On Mon, 7 Jun 1999, Vikrant Rathore wrote:
> > >
> > > > I am trying to append a table radius from another table radiustemp,
> > both
> > > > having the same structure, but want to append only those tuples from
> > > > radiustemp which are not there in radius. The size of the table can be
> > > > up to 165 MB.
> > > > So anyone can suggest me a better way of doing this.
> > > >
> > > > The structure if table is like this .
> > > >
> > > > Table    = radius
> > > >
> > +----------------------------------+----------------------------------+---
> > ----+
> > > >
> > > > |              Field               |              Type
> > |
> > > > Length|
> > > >
> > +----------------------------------+----------------------------------+---
> > ----+
> > > >
> > > > | uname                            | char()
> > > > |   256 |
> > > > | logdate                          | date
> > > > |     4 |
> > > > | logtime                          | time
> > > > |     8 |
> > > > | duration                         | int4
> > > > |     4 |
> > > > | status                           | char()
> > > > |    20 |
> > > > | nasadd                           | char()
> > > > |    20 |
> > > > | port                             | int4
> > > > |     4 |
> > > > | bytesin                          | int4
> > > > |     4 |
> > > > | bytesout                         | int4
> > > > |     4 |
> > > > | packin                           | int4
> > > > |     4 |
> > > > | packout                          | int4
> > > > |     4 |
> > > > | misc                             | int4
> > > > |     4 |
> > > >
> > +----------------------------------+----------------------------------+---
> > ----+
> > > >
> > > > Thank's in advance for your help.
> > > >
> > > > Thanks & regards,
> > > > Vicky
> > > >
> > > insert into RADIUS select * from RADIUSTEMP where UNAME not in (select
> > > UNAME from RADIUS)
> > >
> > > UNAME must be unique. If it is not, than you need to use another field
> > > (for example "code") which will be unique.
> > >
> > > P.S. Nice book about SQL: "Understanding SQL" by Martin Gruber. ISBN
> > > 5-85582-010-6
> > >
> > > @------------------+-----------------------------------------------@
> > > | Fomichev Mikhail | The Government of Kamchatka region.           |
> > > | Vladimirovich    | The Labour and Social Development Department. |
> > > |<fomichev@null.ru>|                                               |
> > > @------------------+-----------------------------------------------@
> >




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

* RE: [SQL] Mail about duplicate rows
@ 1999-06-08 15:37 Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Jackson, DeJuan @ 1999-06-08 15:37 UTC (permalink / raw)
  To: vikrant@chemquick.com, "Jackson, DeJuan" <djackson@cpsgroup.com>; +Cc: Fomichev Michael <fomichev@null.ru>; pgsql-sql

Do you have any indexes on these two tables?
I'd suggest at least one:
  radius(uname. logdate, logtime)
also:
  vacuum analyze radius;
before and after the insert might help performance.
And remember that this will be an expensive query no matter how it's done
(comparing every row of radius to every row of radiustemp).
	-DEJ

> -----Original Message-----
> From:	Vikrant Rathore [SMTP:vikrant@chemquick.com]
> Sent:	Monday, June 07, 1999 9:52 PM
> To:	Jackson, DeJuan
> Cc:	Fomichev Michael; pgsql-sql@postgreSQL.org
> Subject:	Re: [SQL] Mail about duplicate rows
> 
> Dear Jackson and Michael,
> 
>     Thanks very much for your help the query worked. Also can you help in
> one
> more way. It took a lot of time to update the radius table around 5
> minutes, the
> size of the table was around 360 KB's only, so could you suggest a way of
> improving the performance since if i am having a table of around 120 - 165
> MB it
> does not take much time to update the radius table.
> 
> Thanks for your help once again.
> 
> Regards,
> Vicky
> 
> 
> "Jackson, DeJuan" wrote:
> 
> > Then you would use:
> > INSERT INTO radius
> > SELECT * FROM raduistemp r1
> > WHERE NOT EXISTS(SELECT 1 FROM radius r2
> >     WHERE r1.uname=r2.uname AND r1.logdate=r2.logdate AND
> > r1.logtime=r2.logtime);
> >         -DEJ
> >
> > > -----Original Message-----
> > > From: Vikrant Rathore [SMTP:vikrant@chemquick.com]
> > > Sent: Monday, June 07, 1999 12:37 AM
> > > To:   Fomichev Michael
> > > Cc:   pgsql-sql@postgreSQL.org
> > > Subject:      Re: [SQL] Mail about duplicate rows
> > >
> > > Thanks for your help. But as you know the UNAME is not unique in
> radius
> > > logs. The
> > > primary key for this table is (Uname,logdate,logtime).
> > >
> > > So this three fields together forms a primary key of the table.
> > >
> > > Thanks & regards,
> > > Vicky
> > >
> > >
> > > Fomichev Michael wrote:
> > >
> > > > On Mon, 7 Jun 1999, Vikrant Rathore wrote:
> > > >
> > > > > I am trying to append a table radius from another table
> radiustemp,
> > > both
> > > > > having the same structure, but want to append only those tuples
> from
> > > > > radiustemp which are not there in radius. The size of the table
> can be
> > > > > up to 165 MB.
> > > > > So anyone can suggest me a better way of doing this.
> > > > >
> > > > > The structure if table is like this .
> > > > >
> > > > > Table    = radius
> > > > >
> > >
> +----------------------------------+----------------------------------+---
> > > ----+
> > > > >
> > > > > |              Field               |              Type
> > > |
> > > > > Length|
> > > > >
> > >
> +----------------------------------+----------------------------------+---
> > > ----+
> > > > >
> > > > > | uname                            | char()
> > > > > |   256 |
> > > > > | logdate                          | date
> > > > > |     4 |
> > > > > | logtime                          | time
> > > > > |     8 |
> > > > > | duration                         | int4
> > > > > |     4 |
> > > > > | status                           | char()
> > > > > |    20 |
> > > > > | nasadd                           | char()
> > > > > |    20 |
> > > > > | port                             | int4
> > > > > |     4 |
> > > > > | bytesin                          | int4
> > > > > |     4 |
> > > > > | bytesout                         | int4
> > > > > |     4 |
> > > > > | packin                           | int4
> > > > > |     4 |
> > > > > | packout                          | int4
> > > > > |     4 |
> > > > > | misc                             | int4
> > > > > |     4 |
> > > > >
> > >
> +----------------------------------+----------------------------------+---
> > > ----+
> > > > >
> > > > > Thank's in advance for your help.
> > > > >
> > > > > Thanks & regards,
> > > > > Vicky
> > > > >
> > > > insert into RADIUS select * from RADIUSTEMP where UNAME not in
> (select
> > > > UNAME from RADIUS)
> > > >
> > > > UNAME must be unique. If it is not, than you need to use another
> field
> > > > (for example "code") which will be unique.
> > > >
> > > > P.S. Nice book about SQL: "Understanding SQL" by Martin Gruber. ISBN
> > > > 5-85582-010-6
> > > >
> > > > @------------------+-----------------------------------------------@
> > > > | Fomichev Mikhail | The Government of Kamchatka region.           |
> > > > | Vladimirovich    | The Labour and Social Development Department. |
> > > > |<fomichev@null.ru>|                                               |
> > > > @------------------+-----------------------------------------------@
> > >



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


end of thread, other threads:[~1999-06-08 15:37 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-06-07 02:33 Mail about duplicate rows Vikrant Rathore <vikrant@chemquick.com>
1999-06-07 05:11 ` Fomichev Michael <fomichev@null.ru>
1999-06-07 05:37   ` Vikrant Rathore <vikrant@chemquick.com>
1999-06-07 21:37 RE: [SQL] Mail about duplicate rows Jackson, DeJuan <djackson@cpsgroup.com>
1999-06-08 02:52 ` Vikrant Rathore <vikrant@chemquick.com>
1999-06-08 15:37 RE: [SQL] Mail about duplicate rows Jackson, DeJuan <djackson@cpsgroup.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