Re: [SQL] GiST index question: performance

2007-03-06 Thread Peter Eisentraut
Steve Midgley wrote: my ISP that manages my Pg SQL server is (in my interests) concerned about installing anything non-standard (read: unstable) onto their server. I was able to get them to install your TSearch2 b/c it's been proven many times, but I'm hesitant to even bring up Q3C since it's

[SQL] Time of executed query

2007-03-06 Thread Ezequias Rodrigues da Rocha
Hi list, It is possible to retrieve the time of a SQL statement leads to execute ? I would like to put in my application how much time each operation leads to finish. Any suggestion ? -- Ezequias Rodrigues da Rocha http://ezequiasrocha.blogspot.com/ use Mozilla

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
note the time just before your operation starts note the time just after it ends show timeafter - timebefore Ezequias Rodrigues da Rocha [EMAIL PROTECTED] 2007-03-06 14:20 Hi list, It is possible to retrieve the time of a SQL statement leads to execute ? I would like to put in my application

Re: [SQL] Time of executed query

2007-03-06 Thread Ezequias Rodrigues da Rocha
I preffer that the database give me this information. I don't know if it is possible becouse if we retrieve many rows and if we want to put this result in a new column the same time will be replicated many times and consuming more processing. Any other suggestion ? Ezequias 2007/3/6, Bart

[SQL] convert to a string

2007-03-06 Thread Shavonne Marietta Wijesinghe
Hello i have a column N_GEN in postgreSql defined as text. In this coloumn i insert a number 10 N_GEN (text) = 10 on error resume next Set oRs = oConn.Execute(SELECT N_GEN FROM MyTable ORDER BY N_GEN DESC) If err 0 then 'If table not found GetFieldValue = 1 else GetFieldValue =

Re: [SQL] Time of executed query

2007-03-06 Thread Shoaib Mir
Did you try EXPLAIN ANALYZE SQL Query? --- Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 3/6/07, Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: I preffer that the database give me this information. I don't know if it is possible becouse if we retrieve many rows and if we want to put

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
Assuming you're using stored procedures... Start procedure with logging current time, name of procedure,... Perform whatever must be performed End procedure with logging current time, name of procedure,... Query logging table to get time spent Alternative, still assuming you're using stored

Re: [SQL] convert to a string

2007-03-06 Thread Bart Degryse
I assume GetFieldValue is the name of a VB function or property get? Try either Set oRs = oConn.Execute(SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC) or GetFieldValue = cint(oRs(N_GEN)) + 1 or GetFieldValue = clng(oRs(N_GEN)) + 1 In the last two cases make sure that the function

Re: [SQL] convert to a string

2007-03-06 Thread A. Kretschmer
am Tue, dem 06.03.2007, um 14:42:53 +0100 mailte Shavonne Marietta Wijesinghe folgendes: Hello i have a column N_GEN in postgreSql defined as text. In this coloumn i insert a number 10 Why do you store numbers as text? N_GEN (text) = 10 on error resume next Set oRs =

Re: [SQL] Time of executed query

2007-03-06 Thread Ezequias Rodrigues da Rocha
EXPLAIN ANALYZE Is perfect but i have no idea of how to use it. My resultset is retrieving my rows. Another question that cames with the Analyze. PgAdmin return the time to retrieve the data or all time to fill the grid on the SQL Editor. -- Ezequias Rodrigues da Rocha

Re: [SQL] Time of executed query

2007-03-06 Thread Bart Degryse
EXPLAIN ANALYZE is only for tuning purposes. Read the manual (http://www.postgresql.org/docs/8.1/interactive/sql-explain.html) to get more insight Ezequias Rodrigues da Rocha [EMAIL PROTECTED] 2007-03-06 14:55 EXPLAIN ANALYZE Is perfect but i have no idea of how to use it. My resultset is

Re: [SQL] Time of executed query

2007-03-06 Thread Shoaib Mir
EXPLAIN ANALYZE does give the query execution time at the end of its output. -- Shoaib Mir EnterpriseDB (www.enterprisedb.com) On 3/6/07, Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: EXPLAIN ANALYZE Is perfect but i have no idea of how to use it. My resultset is retrieving my rows.

Re: [SQL] convert to a string

2007-03-06 Thread Shavonne Marietta Wijesinghe
when i try the set oRs = oConn.Execute(SELECT N_GEN::int FROM MyTable ORDER BY N_GEN DESC) it returns 1 and for the rest i doens't change. alsways 10 :( - Original Message - From: Bart Degryse To: pgsql-sql@postgresql.org Sent: Tuesday, March 06, 2007 2:54 PM Subject: Re:

Re: [SQL] convert to a string

2007-03-06 Thread Bart Degryse
As Andreas already asked: do you really have a good reason to store numbers as text If so, show us some more information: table definition, some table data, a complete (vb?) function/property get, ... anything that is directly involved. Shavonne Marietta Wijesinghe [EMAIL PROTECTED]

Re: [SQL] convert to a string

2007-03-06 Thread Shavonne Marietta Wijesinghe
i figured it out Set oRs = oConn.Execute(SELECT N_GEN FROM MyTable ORDER BY N_GEN::INT DESC) thanks to everyone - Original Message - From: Shavonne Marietta Wijesinghe To: pgsql-sql@postgresql.org Sent: Tuesday, March 06, 2007 3:32 PM Subject: Re: [SQL] convert to a

[SQL] Selecting exactly one row for each column value

2007-03-06 Thread Florian Weimer
I've got the following table: fweimer= SELECT * FROM tab; a | b | c ---+---+--- 1 | 2 | 3 5 | 6 | 7 1 | 2 | 2 2 | 3 | 4 1 | 2 | 2 2 | 3 | 4 For each value in the first column, I need one (and only one) matching row from the table. A possible solution is: a | b | c ---+---+--- 5 | 6 |

Re: [SQL] Selecting exactly one row for each column value

2007-03-06 Thread A. Kretschmer
am Tue, dem 06.03.2007, um 16:03:36 +0100 mailte Florian Weimer folgendes: Is there a better way to implement this? DISTINCT ON() http://www.postgresql.org/docs/current/static/sql-select.html#SQL-DISTINCT Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639

[SQL] [Fwd: View Vs. Table]

2007-03-06 Thread Radhika Sambamurti
Hi, I have two tables which currently are being aggregated into a third table. I am proposing eliminating or drastically shortening the 3rd aggregation table, and instead just using a View. Which brings me to the question, which is better? Reading from a table or a view or is there a difference

Re: [SQL] Selecting exactly one row for each column value

2007-03-06 Thread Tom Lane
Florian Weimer [EMAIL PROTECTED] writes: For each value in the first column, I need one (and only one) matching row from the table. A possible solution is: SELECT DISTINCT ON would do it, if you don't mind a non-portable solution. regards, tom lane

Re: [SQL] Time of executed query

2007-03-06 Thread Rodrigo De León
On 3/6/07, Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Hi list, It is possible to retrieve the time of a SQL statement leads to execute ? I would like to put in my application how much time each operation leads to finish. Any suggestion ? -- Ezequias Rodrigues da Rocha

Re: [SQL] Time of executed query

2007-03-06 Thread Rodrigo De León
On 3/6/07, Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Hi list, It is possible to retrieve the time of a SQL statement leads to execute ? I would like to put in my application how much time each operation leads to finish. Any suggestion ? -- Ezequias Rodrigues da Rocha

Re: [SQL] Selecting exactly one row for each column value

2007-03-06 Thread Florian Weimer
* Tom Lane: Florian Weimer [EMAIL PROTECTED] writes: For each value in the first column, I need one (and only one) matching row from the table. A possible solution is: SELECT DISTINCT ON would do it, if you don't mind a non-portable solution. Cool, thanks a lot. -- Florian Weimer

Re: [SQL] [Fwd: View Vs. Table]

2007-03-06 Thread Andrew Sullivan
On Tue, Mar 06, 2007 at 09:40:52AM -0500, Radhika Sambamurti wrote: But from the db point of view, is there a bigger performace hit when I query a view Vs a table or is there no difference. It rather depends on your view definition. See the discussion of views and, especially, the discussion

[SQL] Inc

2007-03-06 Thread Ezequias Rodrigues da Rocha
Hi list, There is any function to increment with 1 some field. For example. I have a table with a field that on each update it incrementes a field that is allways configured to 0 before the starting of updates. Regards -- Ezequias Rodrigues da Rocha http://ezequiasrocha.blogspot.com/ use

Re: [SQL] Inc

2007-03-06 Thread Richard Huxton
Ezequias Rodrigues da Rocha wrote: Hi list, There is any function to increment with 1 some field. For example. I have a table with a field that on each update it incrementes a field that is allways configured to 0 before the starting of updates. Something like: CREATE FUNCTION my_autoinc()

Re: [SQL] Inc

2007-03-06 Thread Ezequias Rodrigues da Rocha
Thank you but I must inc an specific row. How to do that ? Ezequias 2007/3/6, Richard Huxton dev@archonet.com: Ezequias Rodrigues da Rocha wrote: Hi list, There is any function to increment with 1 some field. For example. I have a table with a field that on each update it incrementes a

Re: [SQL] Inc

2007-03-06 Thread Richard Broersma Jr
--- Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Thank you but I must inc an specific row. How to do that ? Does, UPDATE your_table SET your_row = your_row +1 WHERE your_pkey = some value; not do what you need? Regards, Richard Broersma Jr. ---(end of

Re: [SQL] GiST index question: performance

2007-03-06 Thread Steve Midgley
Hi Peter, :) All my Pg code is written via (or handed to) an abstraction layer, and I actually write no functions or stored procedures at all. I write using Rails, so in this case it's a Ruby library called ActiveRecord which has a Postgres module that allows me to talk via

Re: [SQL] Inc

2007-03-06 Thread Andreas Kretschmer
Richard Broersma Jr [EMAIL PROTECTED] schrieb: --- Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Thank you but I must inc an specific row. How to do that ? Does, UPDATE your_table SET your_row = your_row +1 WHERE your_pkey = some value; not do what you need? I think, he

Re: [SQL] Inc

2007-03-06 Thread Ezequias Rodrigues da Rocha
Now that's ok. Thank you all. I just thought that there was a function to inc an integer field in postgresql. Best regards Ezequias 2007/3/6, Andreas Kretschmer [EMAIL PROTECTED]: Richard Broersma Jr [EMAIL PROTECTED] schrieb: --- Ezequias Rodrigues da Rocha [EMAIL PROTECTED] wrote: Thank

Re: [SQL] Selecting exactly one row for each column value

2007-03-06 Thread Stefan Becker
Am Dienstag, 6. März 2007 16:03 schrieb Florian Weimer: a | b | c ---+---+--- 5 | 6 | 7 2 | 3 | 4 1 | 2 | 3 Hi, couldn't you accomplish this by: select distinct on (a) * from tablename order by a; here: create table tab (a int,b int,c int); insert into tab values (1,2,3); insert

Re: [SQL] Inc

2007-03-06 Thread Richard Huxton
Ezequias Rodrigues da Rocha wrote: Thank you but I must inc an specific row. How to do that ? I'm not sure I understand. A row in a different table? ... BEGIN UPDATE some_table SET counter = counter + 1; END; ... -- Richard Huxton Archonet Ltd ---(end of

Re: [SQL] GiST index question: performance

2007-03-06 Thread Oleg Bartunov
On Tue, 6 Mar 2007, Steve Midgley wrote: Hi Peter, :) All my Pg code is written via (or handed to) an abstraction layer, and I actually write no functions or stored procedures at all. I write using Rails, so in this case it's a Ruby library called ActiveRecord which has a Postgres module

Re: [SQL] Inc

2007-03-06 Thread Ezequias Rodrigues da Rocha
I did like this: update base.destinationTable set MyCountField = MyCountField + 1 where id = new.keyField_ID; I think it works becouse my tests are ok. My really thank you all. Ezequias 2007/3/6, Richard Huxton dev@archonet.com: Ezequias Rodrigues da Rocha wrote: Thank you but I must inc an

[SQL] best index for ~ ordering?

2007-03-06 Thread Gerardo Herzig
Hi all, i have a large table with one varchar field, and im triyng to get information about what index should i use in order to using that index (if this is possible) for ~ searching, and/or using LIKE searching. Thanks! Gerardo ---(end of

Re: [SQL] best index for ~ ordering?

2007-03-06 Thread Andrew Sullivan
On Tue, Mar 06, 2007 at 06:34:23PM -0300, Gerardo Herzig wrote: Hi all, i have a large table with one varchar field, and im triyng to get information about what index should i use in order to using that index (if this is possible) for ~ searching, and/or using LIKE searching. What sort of

Re: [SQL] How to union table without union statement?

2007-03-06 Thread calendarw
I think the tables should contain 50k rows of record and it should be insert 7k rows per month. And the condition of the database is running, so it should not change the tables to partitioning right now. I am looking for some JOIN statement but still doesn't understand how to use JOIN to

Re: [SQL] best index for ~ ordering?

2007-03-06 Thread gherzig
Well, im wondering if is possible using LIKE '%blah%', even better would be upper/lower(string) like '%blah%', Im not at work right now, i will try it latter and makes you know about the results of using tsearch indexing. Thanks a lot, man! Gerardo On Tue, Mar 06, 2007 at 06:34:23PM -0300,