Обсуждение: Temporary Table

Поиск
Список
Период
Сортировка

Temporary Table

От
"Christian Paul B. Cosinas"
Дата:

Does Creating Temporary table in a function and NOT dropping them affects the performance of the database?

 



I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html



I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html

Re: Temporary Table

От
Alvaro Herrera
Дата:
Christian Paul B. Cosinas wrote:
> Does Creating Temporary table in a function and NOT dropping them affects
> the performance of the database?

The system will drop it automatically, so it shouldn't affect.

What _could_ be affecting you if you execute that function a lot, is
accumulated bloat in pg_class, pg_attribute, or other system catalogs.
You may want to make sure these are vacuumed often.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: Temporary Table

От
Ralph Mason
Дата:
Alvaro Herrera wrote:
> Christian Paul B. Cosinas wrote:
>
>> Does Creating Temporary table in a function and NOT dropping them affects
>> the performance of the database?
>>
>
> The system will drop it automatically, so it shouldn't affect.
>
> What _could_ be affecting you if you execute that function a lot, is
> accumulated bloat in pg_class, pg_attribute, or other system catalogs.
> You may want to make sure these are vacuumed often.
>
>
The answer in my experience is a very loud YES YES YES

If you use lots of temporary tables you will grow and dirty your system
catalogs, so you need to be vacuuming them regularly also (pg_call,
pg_attribute) Otherwise your db will slow to a crawl after a while.

Ralph


Re: Temporary Table

От
"Christian Paul B. Cosinas"
Дата:
In what directory in my linux server will I find these 3 tables?

-----Original Message-----
From: Alvaro Nunes Melo [mailto:al_nunes@atua.com.br]
Sent: Wednesday, October 26, 2005 10:49 AM
To: Christian Paul B. Cosinas
Subject: Re: [PERFORM] Temporary Table

Christian Paul B. Cosinas wrote:

>I am creating a temporary table in every function that I execute.
>Which I think is bout 100,000 temporary tables a day.
>
>
I think that a lot. ;)

>What is the command for vacuuming these 3 tables?
>
>
VACUUM FULL pg_class;
VACUUM FULL pg_attribute;
VACUUM FULL pg_depend;

I'm using this ones. Before using them, take a look in the size that this
tables are using in your HD, and compare to what you get after running this
commands.



I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html


Re: Temporary Table

От
"Christian Paul B. Cosinas"
Дата:
I try to run this command in my linux server.
VACUUM FULL pg_class;
VACUUM FULL pg_attribute;
VACUUM FULL pg_depend;

But it give me the following error:
    -bash: VACUUM: command not found





I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html


Re: Temporary Table

От
"Joshua D. Drake"
Дата:
Christian Paul B. Cosinas wrote:
> I try to run this command in my linux server.
> VACUUM FULL pg_class;
> VACUUM FULL pg_attribute;
> VACUUM FULL pg_depend;
>
> But it give me the following error:
>     -bash: VACUUM: command not found

That needs to be run from psql ...

>
>
>
>
>
> I choose Polesoft Lockspam to fight spam, and you?
> http://www.polesoft.com/refer.html
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org


Re: Temporary Table

От
Christopher Kings-Lynne
Дата:
Ummm...they're SQL commands.  Run them in PostgreSQL, not on the unix
command line...

Christian Paul B. Cosinas wrote:
> I try to run this command in my linux server.
> VACUUM FULL pg_class;
> VACUUM FULL pg_attribute;
> VACUUM FULL pg_depend;
>
> But it give me the following error:
>     -bash: VACUUM: command not found
>
>
>
>
>
> I choose Polesoft Lockspam to fight spam, and you?
> http://www.polesoft.com/refer.html
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org


Re: Temporary Table

От
Christopher Kings-Lynne
Дата:
> In what directory in my linux server will I find these 3 tables?

Directory?  They're tables in your database...


Re: Temporary Table

От
"Christian Paul B. Cosinas"
Дата:
I see.

But How Can I put this in the Cron of my Linux Server?
I really don't have an idea :)
What I want to do is to loop around all the databases in my server and
execute the vacuum of these 3 tables in each tables.

-----Original Message-----
From: Joshua D. Drake [mailto:jd@commandprompt.com]
Sent: Tuesday, November 08, 2005 2:11 AM
To: Christian Paul B. Cosinas
Cc: 'Alvaro Nunes Melo'; pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Temporary Table

Christian Paul B. Cosinas wrote:
> I try to run this command in my linux server.
> VACUUM FULL pg_class;
> VACUUM FULL pg_attribute;
> VACUUM FULL pg_depend;
>
> But it give me the following error:
>     -bash: VACUUM: command not found

That needs to be run from psql ...

>
>
>
>
>
> I choose Polesoft Lockspam to fight spam, and you?
> http://www.polesoft.com/refer.html
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html


Re: Temporary Table

От
Christopher Kings-Lynne
Дата:
Or you could just run the 'vacuumdb' utility...

Put something like this in cron:

# Vacuum full local pgsql database
30 * * * *  postgres  vacuumdb -a -q -z

You really should read the manual.

Chris

Christian Paul B. Cosinas wrote:
> I see.
>
> But How Can I put this in the Cron of my Linux Server?
> I really don't have an idea :)
> What I want to do is to loop around all the databases in my server and
> execute the vacuum of these 3 tables in each tables.
>
> -----Original Message-----
> From: Joshua D. Drake [mailto:jd@commandprompt.com]
> Sent: Tuesday, November 08, 2005 2:11 AM
> To: Christian Paul B. Cosinas
> Cc: 'Alvaro Nunes Melo'; pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] Temporary Table
>
> Christian Paul B. Cosinas wrote:
>
>>I try to run this command in my linux server.
>>VACUUM FULL pg_class;
>>VACUUM FULL pg_attribute;
>>VACUUM FULL pg_depend;
>>
>>But it give me the following error:
>>    -bash: VACUUM: command not found
>
>
> That needs to be run from psql ...
>
>
>>
>>
>>
>>
>>I choose Polesoft Lockspam to fight spam, and you?
>>http://www.polesoft.com/refer.html
>>
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 4: Have you searched our list archives?
>>
>>               http://archives.postgresql.org
>
>
>
> I choose Polesoft Lockspam to fight spam, and you?
> http://www.polesoft.com/refer.html
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster


Re: Temporary Table

От
Jeff Frost
Дата:
You can use the vacuumdb external command.  Here's an example:

vacuumdb --full --analyze --table mytablename mydbname



On Tue, 8 Nov 2005, Christian Paul B. Cosinas wrote:

> But How Can I put this in the Cron of my Linux Server?
> I really don't have an idea :)
> What I want to do is to loop around all the databases in my server and
> execute the vacuum of these 3 tables in each tables.
>
> -----Original Message-----
> From: Joshua D. Drake [mailto:jd@commandprompt.com]
> Sent: Tuesday, November 08, 2005 2:11 AM
> To: Christian Paul B. Cosinas
> Cc: 'Alvaro Nunes Melo'; pgsql-performance@postgresql.org
> Subject: Re: [PERFORM] Temporary Table
>
> Christian Paul B. Cosinas wrote:
>> I try to run this command in my linux server.
>> VACUUM FULL pg_class;
>> VACUUM FULL pg_attribute;
>> VACUUM FULL pg_depend;
>>
>> But it give me the following error:
>>     -bash: VACUUM: command not found
>
> That needs to be run from psql ...
>
>>
>>
>>
>>
>>
>> I choose Polesoft Lockspam to fight spam, and you?
>> http://www.polesoft.com/refer.html
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 4: Have you searched our list archives?
>>
>>                http://archives.postgresql.org
>
>
> I choose Polesoft Lockspam to fight spam, and you?
> http://www.polesoft.com/refer.html
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

--
Jeff Frost, Owner     <jeff@frostconsultingllc.com>
Frost Consulting, LLC     http://www.frostconsultingllc.com/
Phone: 650-780-7908    FAX: 650-649-1954

Re: Temporary Table

От
Andrew McMillan
Дата:
On Tue, 2005-11-08 at 10:22 +0000, Christian Paul B. Cosinas wrote:
> I see.
>
> But How Can I put this in the Cron of my Linux Server?
> I really don't have an idea :)
> What I want to do is to loop around all the databases in my server and
> execute the vacuum of these 3 tables in each tables.

I usually write a small shell script something like:

==================================================
#!/bin/sh

psql somedatabase <<EOQ
  VACUUM this;
  VACUUM that;
  DELETE FROM someotherplace WHERE delete_this_record;
EOQ
==================================================

and so forth...

This makes the SQL quite nicely readable.


Regards,
                    Andrew McMillan.

-------------------------------------------------------------------------
Andrew @ Catalyst .Net .NZ  Ltd,  PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/            PHYS: Level 2, 150-154 Willis St
DDI: +64(4)803-2201      MOB: +64(272)DEBIAN      OFFICE: +64(4)499-2267
            You work very hard.  Don't try to think as well.
-------------------------------------------------------------------------


Вложения