Thread: is there a way
Hello guys, i have a little problem concerning postgres
1) is there a way to time execution of sql statements in postgres without using any frontend languages like php ?
2) is there also a way of inserting 2000000 records to a table without using any frontend languages like php?
thanks
On Thu, 2002-05-02 at 18:45, Dorward Villaruz wrote: > Hello guys, i have a little problem concerning postgres > > 1) is there a way to time execution of sql statements in postgres without using any frontend languages like php ? Not in PostgreSQL itself. Do it from the Unix shell: at '03:15 tomorrow' <<EOC psql -d database < /path/to/sql/script1 psql -d database < /path/to/sql/script2 EOC or use cron for regular events. > 2) is there also a way of inserting 2000000 records to a table without using any frontend languages like php? Create a text file containing the records and use COPY (in psql) -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C "Bless them which persecute you: bless, and curse not." Romans 12:14
Attachment
1) is there a way to time execution of sql statements in postgres without using any frontend languages like php ?
You can use a shell time command to wrap around the psql command. Something like:
$ time psql -f sql_commands_to_execute
pg7.3devel (in CVS) lets you "EXPLAIN ANALYZE SELECT ...", which shows actually processing time for a query as well as each individual processing step (!)
2) is there also a way of inserting 2000000 records to a table without using any frontend languages like php?Write it in plpgsql, plperl, plpython, or (not yet in the official distro) plruby.
Dixit "Dorward Villaruz" <dorwardv@ntsp.nec.co.jp> (le Thu, 2 May 2002 10:45:38 -0700) : � Hello guys, i have a little problem concerning postgres � � 1) is there a way to time execution of sql statements in postgres without using any frontend languages like php ? � 2) is there also a way of inserting 2000000 records to a table without using any frontend languages like php? You always need a frontend language to speak with a server ;-) It may be a general purpose web server side language or it may be other languages like PERL, Python, C... You also have the "psql" unix shell command that gives you interactive session with the postgresql database. Just write your SQL statements in a file and say : psql -f your-filename your-database and your statements will be executed. You can time a unix command with "time cmd" so "time psql -f your-filename your-database". Best regards. Thierry Besancon
On Thursday 02 May 2002 01:45 pm, Dorward Villaruz wrote: > 1) is there a way to time execution of sql statements in postgres without > using any frontend languages like php ? 2) is there also a way of inserting > 2000000 records to a table without using any frontend languages like php? Well, if shell doesn't count as a language, use: time psql -c $query $database where $query is the query you want to time (quoted properly, of course) and $database is the database the query is accessing. The COPY command does the second part -- see the documentation on details of data format, file location, syntax and soforth. -- Lamar Owen WGCR Internet Radio 1 Peter 4:11
On Thu, May 02, 2002 at 10:45:38AM -0700, Dorward Villaruz <dorwardv@ntsp.nec.co.jp> wrote: > Hello guys, i have a little problem concerning postgres > > 1) is there a way to time execution of sql statements in postgres without using any frontend languages like php ? > 2) is there also a way of inserting 2000000 records to a table without using any frontend languages like php? Presumably you want something that doesn't take a lot of typing that you could run from psql? You might try inserting a few values and then use a cross join of this table(s) multiple times to generate a lot of rows.