Re: [GENERAL] Problem compiling on CentOS

2007-06-20 Thread Robin Ericsson

On 6/20/07, Robin Ericsson [EMAIL PROTECTED] wrote:

`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.


Ok solved. This is what the configure-script barfs on. Hacking the
spec-file to change this flag removes this problem.

--
   regards,
   Robin

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org/


[GENERAL] Problem compiling on CentOS

2007-06-19 Thread Robin Ericsson

Hi,

I'm trying to recompile the SRPM with ldap support (maybe this should
be added as an option to the spec?) but it fails to check for ldap_r
due to problems finding my pthread flag in configure.

Snip from configure:
checking whether pthreads work with -pthread... no
...
checking for ldap_simple_bind in -lldap_r... no
configure: error: library 'ldap_r' is required for LDAP

checking the log for why pthread failed:
configure:16390: checking whether pthreads work with -pthread
configure:16478: gcc -o conftest -O2 -g -march=i386 -mcpu=i686
-I/usr/include/et -Wall -Wmissing-prototypes -Wpointer-arith -Winline
-Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing
-pthread -D_GNU_SOURCE  -I/usr/include   -L/usr/lib conftest.c   -lpam
-lssl -lcrypto -lkrb5 -lz -lreadline -ltermcap -lcrypt -ldl -lm  5
`-mcpu=' is deprecated. Use `-mtune=' or '-march=' instead.
conftest.c: In function 'main':
conftest.c:139: warning: null argument where non-null required (argument 1)
conftest.c:140: warning: null argument where non-null required (argument 1)
conftest.c:140: warning: null argument where non-null required (argument 3)
conftest.c:138: warning: 'th' is used uninitialized in this function
configure:16484: $? = 0
configure:16488: test -z
|| test ! -s conftest.err
configure:16491: $? = 0
configure:16494: test -s conftest
configure:16497: $? = 0
configure:16535: result: no

Any ideas? This is a CentOS5 installation, only special I can think of
is that it runs as Xen domU, and I have the same problem on the dom0,
no non Xen available at the moment.

--
   regards,
   Robin

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] changing the /tmp/ lock file?

2007-06-14 Thread Robin Ericsson

On 6/13/07, Ben [EMAIL PROTECTED] wrote:

Why would that be a problem if each is configured to listen on different
addresses?

But maybe a better question to ask would be how people are doing failover
in the case where you have two servers, each handling a seperate set of
data and acting as backup for each other. I fully expect things to go
slower during failover periods, but in my case, that's better than
doubling my hardware.


Why not running them on different ports and proxy the incoming ports
via iptables or something like that based on the current situation on
your backends?

--
   regards,
   Robin

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] simple coordinate system

2007-03-16 Thread Robin Ericsson

On 3/15/07, Webb Sprague [EMAIL PROTECTED] wrote:

http://www.postgresql.org/docs/8.2/static/datatype-geometric.html

Have you looked at these yet?  If not, you asked your question
prematurely and should have read the docs.  If so, in what respect do
they not work for you?


Yes, I've looked at those, I was thinking that point looked like a
good type, but it's only 2d, so maybe I need a hint on how to use this
in a 3d environment.

--
   regards,
   Robin

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


Re: [GENERAL] simple coordinate system

2007-03-16 Thread Robin Ericsson

On 3/16/07, Tom Lane [EMAIL PROTECTED] wrote:

Robin Ericsson [EMAIL PROTECTED] writes:
 Yes, I've looked at those, I was thinking that point looked like a
 good type, but it's only 2d, so maybe I need a hint on how to use this
 in a 3d environment.

Yeah, the built-in geometric types are all 2D.  If you need 3D, perhaps
PostGIS can help --- otherwise you're on your own :-(.  But adding a new
datatype to PG isn't hard, if you can hack C at all.


My hope was that there was something between standard PostgreSQL and
PostGIS as I didn't want to bring in the whole PostGIS into my
application. But probably it's worth it anyways.

--
   regards,
   Robin

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


[GENERAL] simple coordinate system

2007-03-15 Thread Robin Ericsson

Hi,

I'm planning a simple coordinate system, where objects are described
as x, y and z. Are there any contribs or extensions available that can
help me with datatypes, calculation of length between two points, etc?

--
   regards,
   Robin

---(end of broadcast)---
TIP 6: explain analyze is your friend


Re: [GENERAL] simple coordinate system

2007-03-15 Thread Robin Ericsson

On 3/15/07, Webb Sprague [EMAIL PROTECTED] wrote:

... planning a simple coordinate system, where objects are described
 as x, y and z. Are there any contribs or extensions available that can
 help me with datatypes, calculation of length between two points, etc?

google postgis.  It is for geographic stuff, so maybe overkill, but
maybe not.  There are are also geometry types native to Postgres that
you can find in the docs


I was thinking about PostGIS, but it seemed overkill for my purpose.
Therefore I asked in the first place :)

--
   regards,
   Robin

---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [GENERAL] PostgreSQL and Munin

2006-10-19 Thread Robin Ericsson

On 10/19/06, DANTE Alexandra [EMAIL PROTECTED] wrote:


My problem is that I have not found any RPM for perl-rrdtool and
rrdtool for IA64 and RHEL4-AS (for the others, it's OK).
Does someone know where I can find them or tell me where I can find the
associated tar.gz archive ?


Download the source rpms and build them yourself?

--
   regards,
   Robin

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [GENERAL] PostgreSQL and Munin

2006-10-19 Thread Robin Ericsson

On 10/19/06, DANTE Alexandra [EMAIL PROTECTED] wrote:

Hello Robin, hello List,

Can I use it on RHEL4-AS ? I also tried to find the rpm sources on the
Red Hat web site, without success...
/index.php3/stat/3/srodzaj/2/search/rrdtool-1.2.13-1.fc3.rf.src.rpm


Download the source and try. rpmbuild --rebuild *.src.rpm. If it
doesn't work at least you have .spec file you can use to tweak it to
work.

--
   regards,
   Robin

---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org/


Re: [GENERAL] What is the Best Postgresql Load Balancing Solution available ?

2006-09-18 Thread Robin Ericsson

On 9/18/06, Najib Abi Fadel [EMAIL PROTECTED] wrote:

Hi,

i was searching for a load balancing solution for
postgres, I found some ready to use software like
PGCluster, Slony, pgpool and others.

It would really be nice if someone knows which one is
the best taking in consideration that i have an
already running application that i need to load
balance.


There isn't one tool that is the best, all three work very good based
on where they are used and what they are used for.

--
   regards,
   Robin

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [GENERAL] Messages to pgsql-general list not being posted

2006-07-19 Thread Robin Ericsson

On 7/19/06, Roman Neuhauser [EMAIL PROTECTED] wrote:

Both are in my pgsql-general maildir, message ids:
[EMAIL PROTECTED] [EMAIL PROTECTED]


I find those as well.


regards,
   Robin

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq


Re: [GENERAL] Problem in creating a table

2005-05-17 Thread Robin Ericsson
Wen Guangcheng wrote:
 Hi Gurus,

Hi!

 CREATE TABLE TD_ACCESSCOUNT(
 AC_YEAR NUMBER(4,0)NOT NULL,
 AC_MONTHNUMBER(2,0)NOT NULL,
 AC_DAYS NUMBER(2,0)NOT NULL,
 OFFICE_ID   VARCHAR2(7)NOT NULL,
 AC_COUNTNUMBER(6,0)   DEFAULT 0,
 PRIMARY KEY("AC_YEAR","AC_MONTH","AC_DAYS","OFFICE_ID")
 )
 TABLESPACE RAPIS;
  ^^

 psql:/opt/rapisa/sql/TD_ACCESSCOUNT.sql:14: ERROR:  syntax error at or near 
 "(" at character 52
 #
 
 I really don't know what is wrong with it and do appreciate it if anyone would
 point out it. The version of Postgresql is 7.4.7.
 Thanks in advance.

Tablespace wasn't supported until 8.0



regards,
Robin

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly

Re: [GENERAL] Problem in creating a table

2005-05-17 Thread Robin Ericsson
Wen Guangcheng wrote:

Hi,

 TABLESPACE RAPIS;
 psql:/opt/rapisa/sql/TD_ACCESSCOUNT.sql:14: ERROR:  syntax error at or near 
 "(" at character 52

 I really don't know what is wrong with it and do appreciate it if anyone would
 point out it. The version of Postgresql is 7.4.7.
 Thanks in advance.

Tablespace wasn't supported until 8.0



regards,
Robin

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [GENERAL] [HACKERS] plPHP in core?

2005-04-05 Thread Robin Ericsson
Martijn van Oosterhout wrote:
I suppose the choice comes down to either PHP splitting the DB access
(like other languages) or PostgreSQL splitting out pl/PHP.
Most major distributions (Fedora Core, Debian, Redhat) splits core php 
and database-access in different packages. Might be that sqlite is core, 
that newer php that have that change also bundles libsqlite.

php
php-mysql
php-pgsql
...

regards,
Robin
---(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


Re: [GENERAL] [HACKERS] plPHP in core?

2005-04-05 Thread Robin Ericsson
Martijn van Oosterhout wrote:
On Tue, Apr 05, 2005 at 11:17:48AM +0200, Robin Ericsson wrote:
Martijn van Oosterhout wrote:
I suppose the choice comes down to either PHP splitting the DB access
(like other languages) or PostgreSQL splitting out pl/PHP.
Most major distributions (Fedora Core, Debian, Redhat) splits core php 
and database-access in different packages. Might be that sqlite is core, 
that newer php that have that change also bundles libsqlite.

Ah yes, I meant to check this but packages.debian.org is down. From my
Sources file, php3-pgsql is generated from the main php3 package. But
php4-pgsql has its own source bundle. Maybe the problem is solved?
Ah, you mean it that way. I can't say for debian as the site is still 
down :) But atleast Fedore Core uses one main package to generate all 
binary packages, so I guess the problem is still there.

regards,
Robin
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [GENERAL] 8.0.2beta1 RPMs

2005-04-02 Thread Robin Ericsson
Devrim GUNDUZ wrote:
PostgreSQL RPM Building Project[1] has built RPMs for 8.0.2beta1. RPMs 
for Red Hat Linux 9, Red Hat Enterprise Linux Enterprise Server 3.0, 
Fedora Cor 1,2,3 are now available, and more to come later.
Are the Fedora Core packages compatible with packages from Fedora Core 
itself? I.e, files will be at the same places if I upgrade from FC packages?

regards,
Robin
--
Robin Ericsson
http://robin.vill.ha.kuddkrig.nu/
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq


Re: [GENERAL] LWM 2004 Readers' Choice Nomination

2005-03-28 Thread Robin Ericsson
Christopher Browne wrote:
The poll isn't about OSS; it's a popularity contest for proprietary
software that runs on Linux.
It's interesting to see that MySQL is only third at the moment.
regards,
Robin
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] prelimiary performance comparison pgsql vs mysql

2005-03-20 Thread Robin Ericsson
Mark Rae wrote:
I would say that doing the concurrency tests is probably the most
important factor in comparing other databases against MySQL, as
MySQL will almost always win in single-user tests.
E.g. here are some performance figures from tests I have done in the past.
This is with a 6GB databse on a 4CPU Itanium system running a mixture of
read-only queries, but it is fairly typical of the behaviour I have seen. 
The Oracle figures also scaled in a similar way to postgres.

Clients   1 2 3 4 6 812163264   128
---
mysql-4.1.11.00  1.41  1.34  1.16  0.93  1.03  1.01  1.00  0.94  0.86  0.80
pg-7.4.1   0.65  1.27  1.90  2.48  2.45  2.50  2.48  2.51  2.49  2.39  2.38
Would be interesting to know about the tuning of the MySQL, I guess that 
 buffers for indexing and sort is well setup, but what about thread 
caching? Knowing that will once in a while you will have a connection 
burst you can tell mysql to cache thread so that it can save time next 
time it needs them.

--
Robin Ericsson
http://robin.vill.ha.kuddkrig.nu/
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq


Re: [GENERAL] PostGreSQL upgrade failed (Debian Packages), need

2004-11-24 Thread Robin Ericsson
On Wed, 2004-11-24 at 08:30 -0800, Joshua D. Drake wrote:
 Peter Eisentraut wrote:
 
 Joshua D. Drake wrote:
   
 
 Well you can't just upgrade 7.2.1 to 7.4.6. You have to dump and
 restore.
 
 
 
 The Debian package does that automatically.  On some days...
   
 
 Really? WOW! I wonder if Gentoo does that. That is pretty
 remarkable.

Gentoo tells you that you need to dump and remove the cluster before it
evens tries to upgrade, atleast did for me when going from 7.3 to 7.4



regards,
Robin


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[GENERAL] not using index through procedure

2004-10-14 Thread Robin Ericsson
After some discussion on performance list, I guess this is back to a
general question :)

This is very simplified query of my real problem, but it should show the
way of the problems.

CREATE OR REPLACE FUNCTION ago(interval) RETURNS timestamp AS
'SELECT (now() - $1)::timestamp without time zone'
  LANGUAGE 'sql' IMMUTABLE STRICT;

This query uses the index without problem.
SELECT entered
FROM data
WHERE ago('60 seconds')  data.entered;

However using this function
CREATE OR REPLACE FUNCTION get_machine_status(interval) RETURNS
timestamp AS
'SELECT entered
FROM data
WHERE ago($1)  data.entered
' LANGUAGE 'sql' VOLATILE;

and call it like this:
select * from get_machine_status('60 seconds');
makes the query not use index, I guess it some basic problem I'm having,
maybe I should make this into a view instead?


Regards,
Robin


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] not using index through procedure

2004-10-14 Thread Robin Ericsson
Martijn van Oosterhout [EMAIL PROTECTED] wrote:

 One's marked VOLATILE, the other is marked IMMUTABLE. This affects
 whether it's considered a constant, the planner estimates and hence
 whether it uses the index.

Is there even a way to solve it this way via a procedure?

I've tried different approaches, with moving the ago outside the procedure,
having the procedure take timestamp as argument instead of interval, but still
no luck.

However, remove the $1 argument all together and replace that with ago('60
seconds') makes the procedure fly.


Regards,
Robin
_
This mail sent using V-webmail - http://www.v-webmail.org


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [GENERAL] [PERFORM] query problem

2004-10-13 Thread Robin Ericsson
On Wed, 2004-10-13 at 18:01 +0200, Robin Ericsson wrote:
 Using exact timestamp makes the query go back as it should in speed (see
 explain below). However I still have the problem using a stored
 procedure or even using the ago-example from above.

Well, changing ago() to use timestamp without time zone it goes ok in
the query. This query now takes ~2ms.

SELECT
data.entered,
data.machine_id,
datatemplate_intervals.template_id,
data_values.value
FROM
data, data_values, datatemplate_intervals
WHERE
datatemplate_intervals.id = data_values.template_id AND
data_values.data_id = data.id AND
data.machine_id IN (SELECT machine_id FROM machine_group_xref
WHERE group_id = 1) AND
ago('60 seconds')  data.entered

Using it in this procedure.
select * from get_current_machine_status('60 seconds', 1);
takes ~100s. Maybe there's some obvious wrong I do about it?

CREATE TYPE public.mstatus_holder AS
   (entered timestamp,
machine_id int4,
template_id int4,
value varchar);
CREATE OR REPLACE FUNCTION public.get_current_machine_status(interval,
int4)
  RETURNS SETOF mstatus_holder AS
'
SELECT
data.entered,
data.machine_id,
datatemplate_intervals.template_id,
data_values.value
FROM
data, data_values, datatemplate_intervals
WHERE
datatemplate_intervals.id = data_values.template_id AND
data_values.data_id = data.id AND
data.machine_id IN (SELECT machine_id FROM machine_group_xref WHERE
group_id = $2) AND
ago($1)  data.entered
'
  LANGUAGE 'sql' VOLATILE;


Regards,
Robin



---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [GENERAL] [PERFORM] query problem

2004-10-13 Thread Robin Ericsson
Sorry, this should have been going to performance.



Regards,
Robin


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [GENERAL] query gone haywire :)

2004-10-12 Thread Robin Ericsson
On Fri, 2004-10-08 at 10:11 -0400, Tom Lane wrote:
 Robin Ericsson [EMAIL PROTECTED] writes:
   -  Index Scan using idx_d_entered on data  (cost=0.00..18024.04 
  rows=50360 width=16) (actual time=0.210..0.247 rows=1 loops=1)
 Index Cond: 'now'::text)::timestamp(6) with time 
  zone)::timestamp without time zone - '00:01:00'::interval)  entered)
 
 You're running into the well-known problem that the planner can't make
 good estimates for index conditions that involve non-constant terms
 (such as CURRENT_TIMESTAMP).  Lacking a decent estimate, it guesses that
 this scan will produce many more rows than it really will, and so it
 tends to favor plans that would be good in that scenario, but are not
 optimal for retrieving just a couple of rows.
 
 One workaround is to do the date arithmetic on the client side; another
 is to cheat by hiding the arithmetic in a function like ago(interval)
 that you lyingly claim is IMMUTABLE.  See the pgsql-performance
 archives.

I did run a new explain analyze on the query and found the attached
result.

status=# EXPLAIN ANALYZE
status-# SELECT
status-# data.entered,
status-# data.machine_id,
status-# datatemplate_intervals.template_id,
status-# data_values.value
status-# FROM
status-# data, data_values, datatemplate_intervals
status-# WHERE
status-# datatemplate_intervals.id = data_values.template_id AND
status-# data_values.data_id = data.id AND
status-# data.machine_id IN (2,3) AND
status-# current_timestamp::timestamp - interval '60 seconds' 
data.entered;

It seems very strange that it does a full index scan on idx_dv_data_id.



Regards,
Robin

 Hash Join  (cost=28646.01..274260.15 rows=555706 width=24) (actual 
time=102323.087..102323.196 rows=5 loops=1)
   Hash Cond: (outer.template_id = inner.id)
   -  Merge Join  (cost=28644.09..265922.62 rows=555706 width=24) (actual 
time=102322.632..102322.709 rows=5 loops=1)
 Merge Cond: (outer.data_id = inner.id)
 -  Index Scan using idx_dv_data_id on data_values  (cost=0.00..205034.19 
rows=9580032 width=16) (actual time=17.503..86263.130 
rows=9596747 loops=1)
 -  Sort  (cost=28644.09..28870.83 rows=90697 width=16) (actual 
time=0.829..0.835 rows=1 loops=1)
   Sort Key: data.id
   -  Index Scan using idx_d_entered on data  (cost=0.00..20202.81 
rows=90697 width=16) (actual time=0.146..0.185 rows=1 loops=1)
 Index Cond: 'now'::text)::timestamp(6) with time 
zone)::timestamp without time zone - '00:01:00'::interval)  entered)
 Filter: ((machine_id = 2) OR (machine_id = 3))
   -  Hash  (cost=1.74..1.74 rows=74 width=8) (actual time=0.382..0.382 rows=0 
loops=1)
 -  Seq Scan on datatemplate_intervals  (cost=0.00..1.74 rows=74 width=8) 
(actual time=0.024..0.250 rows=74 loops=1)
 Total runtime: 102323.491 ms
(13 rows)


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[GENERAL] query gone haywire :)

2004-10-08 Thread Robin Ericsson
The query have been running ok for some time now, but this morning I
decided to run vacuum analyze (vacuumdb -a -z) on the cluster, and
suddenly the query isn't running very well at all. This query has only
one value in the IN, if I add another id the query becomes really
really slow.

Query:
SELECT
data.entered,
data.machine_id,
datatemplate_intervals.template_id,
data_values.value
FROM
data, data_values, datatemplate_intervals
WHERE
datatemplate_intervals.id = data_values.template_id AND
data_values.data_id = data.id AND
data.machine_id IN (2) AND
current_timestamp::timestamp - interval '60 seconds'  data.entered

Indexes exists on data_values.template_id, data.entered,
data.machine_id, datatemplate_intervals.machine_id,
datatemplate_intervals.template_id.

Data contains almost 1.5milj entries, and data_values around 9.1milj. As
I write this letter I check the tables in pgAdmin, and it tells me this
for table data 
Rows (estimated) 1
Rows (counted)   1491401
 even though I run vacuum analyze on the table itself from pgadmin.

Explain analyze result attached as explain-analyze.txt

Explain without analyze when using IN(2,3) attached as explain.txt


Regards,
Robin
 Hash Join  (cost=1.93..175359.44 rows=152524 width=24) (actual time=0.972..1.085 
rows=5 loops=1)
   Hash Cond: (outer.template_id = inner.id)
   -  Nested Loop  (cost=0.00..173069.64 rows=152524 width=24) (actual 
time=0.274..0.358 rows=5 loops=1)
 -  Index Scan using idx_d_entered on data  (cost=0.00..18024.04 rows=50360 
width=16) (actual time=0.210..0.247 rows=1 loops=1)
   Index Cond: 'now'::text)::timestamp(6) with time zone)::timestamp 
without time zone - '00:01:00'::interval)  entered)
   Filter: (machine_id = 2)
 -  Index Scan using idx_dv_data_id on data_values  (cost=0.00..3.04 rows=3 
width=16) (actual time=0.049..0.074 rows=5 loops=1)
   Index Cond: (data_values.data_id = outer.id)
   -  Hash  (cost=1.74..1.74 rows=74 width=8) (actual time=0.438..0.438 rows=0 
loops=1)
 -  Seq Scan on datatemplate_intervals  (cost=0.00..1.74 rows=74 width=8) 
(actual time=0.028..0.255 rows=74 loops=1)
 Total runtime: 1.575 ms
(11 rows)

 Hash Join  (cost=27010.45..254388.49 rows=253820 width=24)
   Hash Cond: (outer.template_id = inner.id)
   -  Merge Join  (cost=27008.52..250579.25 rows=253820 width=24)
 Merge Cond: (outer.data_id = inner.id)
 -  Index Scan using idx_dv_data_id on data_values  (cost=0.00..197001.44 
rows=9127404 width=16)
 -  Sort  (cost=27008.52..27218.04 rows=83806 width=16)
   Sort Key: data.id
   -  Index Scan using idx_d_entered on data  (cost=0.00..19266.46 
rows=83806 width=16)
 Index Cond: 'now'::text)::timestamp(6) with time 
zone)::timestamp without time zone - '00:01:00'::interval)  entered)
 Filter: ((machine_id = 2) OR (machine_id = 3))
   -  Hash  (cost=1.74..1.74 rows=74 width=8)
 -  Seq Scan on datatemplate_intervals  (cost=0.00..1.74 rows=74 width=8)
(12 rows)


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[GENERAL] Join a varchar array

2004-06-17 Thread Robin Ericsson
Hi,

I have a field in which I save the follow:
{{8,0.58},{9,972420},{10,239544},{6,0.49},{7,0.63}}

The first field is a reference to an id in another table and the second
field is a value.

Can these values be used somehow in a select query to join the other
table?

I don't mind getting them on different rows but I would prefer to 
get them back as an array.


regards
Robin


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [GENERAL] Join a varchar array

2004-06-17 Thread Robin Ericsson
On Thu, 2004-06-17 at 11:38, Richard Huxton wrote:
 Robin Ericsson wrote:
  Hi,
  
  I have a field in which I save the follow:
  {{8,0.58},{9,972420},{10,239544},{6,0.49},{7,0.63}}
  
  The first field is a reference to an id in another table and the second
  field is a value.
  
  Can these values be used somehow in a select query to join the other
  table?
 
 You appear to be using the array as a replacement for a table. Don't do 
 that. From the little information you've provided, it looks like you 
 want a separate table (a_ref, b_ref, float_val) where a_ref references 
 the current table, b_ref the other table.

Thats correct, I choose this way because there will be a lot of entries
and it will grow pretty quickly, but maybe postgres will be able to
handle this?

If I went for a separate table it will contain over 3 milj. entries
within in a couple of weeks and still grow after that but not at the
same speed as the first weeks.



regards
Robin


---(end of broadcast)---
TIP 8: explain analyze is your friend


[GENERAL] dynamic parameters in procedure

2004-05-21 Thread Robin Ericsson
Hi,

I want to create a stored procedure that can take a dynamic number of
in-parameters and base an inside-query based on those parameters.

My ideas was to use text[] as input parameters like this.

CREATE OR REPLACE FUNCTION get_table(text[])
  RETURNS SETOF table AS
'
 DECLARE
params ALIAS FOR $1;
query VARCHAR;
entry RECORD;
 BEGIN
query := \'SELECT * FROM table\';

FOR entry IN EXECUTE query LOOP
RETURN NEXT entry;
END LOOP;
RETURN;
 END;
'
  LANGUAGE 'plpgsql';

My question is how do I loop the input-parameters?

I plan to call it like this: 

SELECT * FROM get_table('{field1=1, field2=3}');

Do I make any sense? :)


regards
Robin


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])