Friday, May 30, 2008

Re: [HACKERS] Core team statement on replication in PostgreSQL

Hi Tom,

Thanks for the reasoned reply. As you saw from point #2 in my comments, I
think you should do this feature. I hope this answers Josh Berkus' concern
about my comments.

You make a very interesting comment which seems to go to the heart of this
design approach:

> About the only thing that would make me want to consider row-based
> replication in core would be if we determine that read-only slave
> queries are impractical atop a WAL-log-shipping implementation.

It's possible I'm misunderstanding some of the implementation issues, but it
is striking that the detailed responses to your proposal list a number of
low-level dependencies between master and slave states when replicating WAL
records. It appears that you are designing a replication mechanism that
works effectively between a master and a relatively small number of "nearby"
slaves. This is clearly an important use case but it also seems clear that
the WAL approach is not a general-purpose approach to replication. In other
words, you'll incrementally get to that limited end point I describe. This
will still leave a lot to be desired on read scaling, not to mention many
other cases.

Hence my original comments. However, rather than harp on that further I
will open up a separate thread to describe a relatively small set of
extensions to PostgreSQL that would be enabling for a wide range of
replication applications. Contrary to popular opinion these extensions are
actually well understood at the theory level and have been implemented as
prototypes as well as in commercial patches multiple times in different
databases. Those of us who are deeply involved in replication deserve just
condemnation for not stepping up and getting our thoughts out on the table.

Meanwhile, I would be interested in your reaction to these thoughts on the
scope of the real-time WAL approach. There's obviously tremendous interest
in this feature. A general description that goes beyond the NTT slides
would be most helpful for further discussions.

Cheers, Robert

P.s., The NTT slides were really great. Takahiro and Masao deserve
congratulations on an absolutely first-rate presentation.

On 5/29/08 9:09 PM, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:

> Andrew Sullivan <ajs@commandprompt.com> writes:
>> On Thu, May 29, 2008 at 12:05:18PM -0700, Robert Hodges wrote:
>>> people are starting to get religion on this issue I would strongly
>>> advocate a parallel effort to put in a change-set extraction API
>>> that would allow construction of comprehensive master/slave
>>> replication.
>
>> You know, I gave a talk in Ottawa just last week about how the last
>> effort to develop a comprehensive API for replication failed.
>
> Indeed, core's change of heart on this issue was largely driven by
> Andrew's talk and subsequent discussion. We had more or less been
> waiting for the various external replication projects to tell us
> what they wanted in this line, and it was only the realization that
> no such thing was likely to happen that forced us to think seriously
> about what could be done within the core project.
>
> As I said originally, we have no expectation that the proposed features
> will displace the existing replication projects for "high end"
> replication problems ... and I'd characterize all of Robert's concerns
> as "high end" problems. We are happy to let those be solved outside
> the core project.
>
> About the only thing that would make me want to consider row-based
> replication in core would be if we determine that read-only slave
> queries are impractical atop a WAL-log-shipping implementation.
> Which could happen; in fact I think that's the main risk of the
> proposed development plan. But I also think that the near-term
> steps of the plan are worth doing anyway, for various other reasons,
> and so we won't be out too much effort if the plan fails.
>
> regards, tom lane
>


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

You'll need to get a particular revision of MediaWiki that is PG 8.3
compatible:

http://people.planetpostgresql.org/greg/index.php?/archives/123-

MediaWiki-is-Postgres-8.3-compatible.html

Once that's done, it works fine (at least for me).

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [Fwd: Re: [planet] Can I have my feed shown on planetpostgresql.org?]

Looks good to me.

//Magnus

Devrim GÜNDÜZ wrote:
>
> Any objections?
>
> -------- Forwarded Message --------
> > From: Kenny Gorman <kgorman@kennygorman.com>
> > To: Devrim GÜNDÜZ <devrim@gunduz.org>
> > Cc: Kenny Gorman <kgorman@kennygorman.com>, planet@postgresql.org
> > Subject: Re: [planet] Can I have my feed shown on
> > planetpostgresql.org?
> > Date: Fri, 30 May 2008 02:44:58 -0700
> >
> > Devrim,
> >
> > Sure, here you go, I think this works..
> >
> > http://www.kennygorman.com/wordpress/?cat=7&feed=atom
> >
> > -kg
> >
> > On May 30, 2008, at 12:41 AM, Devrim GÜNDÜZ wrote:
> >
> > >
> > > Hi,
> > >
> > > Do you have a specific category for PostgreSQL, which includes
> > > all PostgreSQL related stuff? I'd like to pull that one instead
> > > of whole feed.
> > >
> > > Regards, Devrim
> > >
> > > On Wed, 28 May 2008, Kenny Gorman wrote:
> > >
> > >> I generally blog about PostgreSQL, Slony, Oracle, python,
> > >> scalability and other fun DB related stuff, I work at
> > >> www.hi5.com where we do some fun stuff with PostgreSQL.
> > >>
> > >> site:
> > >>
> > >> www.kennygorman.com
> > >>
> > >> feed:
> > >>
> > >> http://www.kennygorman.com/wordpress/?feed=atom
> > >>
> > >
> > > --
> > > Devrim GÜNDÜZ
> > > RHCE, PostgreSQL Consultant @ Command Prompt, Inc.
> > >

http://www.CommandPrompt.com
> > > devrim~gunduz.org, devrim~PostgreSQL.org,
> > > devrim.gunduz~linux.org.tr http://www.gunduz.org
> >
> >
> --
> Devrim GÜNDÜZ , RHCE
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
> Managed Services, Shared and Dedicated Hosting
> Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/


--
Sent via planet mailing list (planet@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/planet

Re: [pgsql-www] Roadmap web page

Stefan Kaltenbrunner wrote:
> Bruce Momjian wrote:
> > Do we need to update the URLs on the roadmap page to point to the wiki
> > instead?
> >
> >

http://www.postgresql.org/developer/roadmap
>
> what urls and what wording would you think is appropriate - we could
> either link to
> http://wiki.postgresql.org/wiki/PostgreSQL_8.4_Development_Plan or
> include that exact information on the website - or what else do you have
> in mind ?

I would like us to use consistent URLs based on ISO dates rather than
month names, and have a fixed URL that points to the most recent
commit-fest, and then link to that from the web site.

--
Bruce Momjian <bruce@momjian.us>

http://momjian.us

EnterpriseDB

http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

--
Sent via pgsql-www mailing list (pgsql-www@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-www

Re: [SQL] Weeks elapsed to Months elapsed conversion

On Fri, May 30, 2008 at 4:21 AM, Allan Kamau <allank@sanbi.ac.za> wrote:
> Expected tests may be:
> 14 weeks yields 3 months.
> 1 weeks yields 0 months.

Assuming 4 week months:

SELECT 14 / 4 AS "3 months", 1 / 4 AS "0 months"

3 months | 0 months
----------+----------
3 | 0
(1 row)

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Re: [GENERAL] Tsearch2 Upgrade from 8.2 to 8.3.1 with mediawiki

Hello!

I found the solution:
Normal export.
Normal upgrade procedure.

su - postgres

# Upgrade tsearch2
# http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/tsearch-V2-intro.html
createdb wikidb
psql wikidb < /usr/share/pgsql/contrib/tsearch2.sql

psql < pg_dumpall.sql postgres

Ciao,
Gerhard

--
http://www.wiesinger.com/


On Thu, 15 May 2008, Gerhard Wiesinger wrote:

> Hello!
>
> I want to upgrade from 8.2 to 8.3.1 but I've problems:
> I did a pg_dumpall but this doesn't work. I found the migration guide with a
> trick to load the new contrib/tsearch2 module. But how is this done exactly?
> -------------------------------------------------------------------------
> http://www.postgresql.org/docs/8.3/interactive/textsearch-migration.html
> The old contrib/tsearch2 functions and other objects must be suppressed when
> loading pg_dump output from a pre-8.3 database. While many of them won't load
> anyway, a few will and then cause problems. One simple way to deal with this
> is to load the new contrib/tsearch2 module before restoring the dump; then it
> will block the old objects from being loaded.
> -------------------------------------------------------------------------
>
> Some other link I've found:
> http://sql-info.de/postgresql/notes/converting-tsearch2-to-8.3.html
> http://www.sai.msu.su/~megera/wiki/Tsearch2_83_changes
> http://archives.postgresql.org/pgsql-hackers/2007-10/msg00509.php
>
> http://translate.google.com/translate?u=http%3A%2F%2Fwww.nabble.com%2FAtualiza%25C3%25A7%25C3%25A3o-de-Mediawiki-para-8.3-td15722654.html&hl=en&ie=UTF8&sl=es&tl=en
> http://www.postgresql.org/docs/8.3/interactive/textsearch-migration.html
> http://www.postgresql.org/docs/current/static/tsearch2.html#AEN102824
> http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/
> http://people.planetpostgresql.org/greg/index.php?/archives/123-MediaWiki-is-Postgres-8.3-compatible.html
>
> Thank you.
>
> Ciao,
> Gerhard
>
> --
> http://www.wiesinger.com/
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Query planning configuration and solid state drives

On Fri, May 30, 2008 at 11:43 AM, Clodoaldo
<clodoaldo.pinto.neto@gmail.com> wrote:
> What should be changed in the query planning configuration, if at all,
> if a ultrafast solid state drive would be used to host a whole
> database ? Specially if used in Raid 0 configurations.

random_page_cost can probably be reduced...

is this flash ssd?

merlin

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Query planning configuration and solid state drives

On Fri, May 30, 2008 at 9:43 AM, Clodoaldo
<clodoaldo.pinto.neto@gmail.com> wrote:
> What should be changed in the query planning configuration, if at all,
> if a ultrafast solid state drive would be used to host a whole
> database ? Specially if used in Raid 0 configurations.

Well, random page cost should be about 1.0

Not sure other than that.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [pgsql-es-ayuda] Hacer una firma digital con sha-1

Hola Miguel,

Eso depende de lo que quieras vos, pero te diría que si querés firmar el
registro lo lógico parece ser hacer sha(campo_1||campo_2|| ... ||campo_n||'
alguna cadena secreta ')

De esa manera, para alterar el registro y poder cambiar correctamente el
hash, deberías conocer la cadena secreta ... Se me ocurre que tal vez se
puede hacer con un trigger para el cual el usuario que ejecuta la consulta
de inserción del hash no tenga permisos(Y por lo tanto no vea la
definición), pero que esté declarado como security definer. Probablemente
alguien de la lista te pueda dar más presiciones al respecto ;)

Saludos.

Pablo.

----- Original Message -----
From: "Miguel Beltran R." <yourpadre@gmail.com>
To: <pgsql-es-ayuda@postgresql.org>
Sent: Thursday, May 29, 2008 4:26 PM
Subject: [pgsql-es-ayuda] Hacer una firma digital con sha-1


Hola lista

Si tengo esta estructura

TABLE bitacota (
foraneo integer not null,
taller integer not null,
contrasena varying(20) not null,
fecha date not null,
hora_cap time without timezone,
tapon varying (1), --valores validos son "B", "M", "N"
placa varying (10),
hash_sha varying (20)
)

¿cómo puedo calcular el hash de cada registro? Ya lei como se calcula
el hash de un campo (aunque aun no le entiendo bien al algoritmo),
pero ¿cómo es para calcular de todos los campos?¿sumo el hash de todos
los campos y ese es el hash del registro?


--
________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
--
TIP 10: no uses HTML en tu pregunta, seguro que quien responda no podrá
leerlo

--
TIP 1: para suscribirte y desuscribirte, visita http://archives.postgresql.org/pgsql-es-ayuda

Re: [opensuse-es] Re: [pgsql-es-ayuda] pl/pgsql para torpes

Perdon mi intención no era mandarlo 3 veces pero es que el mensaje nunca me
llegaba, los envie a las 11 y a las 2 todavía no las había recibido.

Aprovecho para preguntaros si hay una guia rapida de pl/pgsql es castellano, he
visto una y no consigo mucho

No entiendo bien como introducir las variables en las cadenas de los execute, yo
intento montar la cadena con el valor , pero creo que debe de ser de otra manera,
supongo que poniendo variables que en el momento de ejecución va ha sustituir, lo
hago de esta forma :


aux0 := 'select distinct
c.empresa,to_number(to_char(c.fecha,''YYYYMMDDHH24''),''9999999999''),to_number(to_char(c.fecha,''YYYY''),''9999''),

to_number(to_char(c.fecha,''Q''),''9'') to_number(to_char(c.fecha,''MM''),''99''),
to_number(to_char(c.fecha,''W''),''9''),
to_number(to_char(c.fecha,''WW''),''99''),
to_number(to_char(c.fecha,''ID''),''9''),
> > to_number(to_char(c.fecha,''DD''),''99'')
> > > from gc05albc c,gc06albl l
> >
> > > where c.empresa = ''' ||
> > dw01.empresa || '''
> > > and c.serie =
> > l.serie
> > > and c.albaran =
> > l.albaran
> > > and c.fecha >=''' ||
> > dw01.fecha_inicial
> > > || '''
> >
> > > and c.proveedor =
> > l.proveedor
> > > and l.tipo = 1
> >
> > > and l.unidades 0
> >
> > > and length(l.articulo) = 0';
> >
> > > end if;
> >
> > >
> >
> > > OPEN dw0_0010_1_c FOR EXECUTE aux0;
> >
> > >
> >
> > > RAISE NOTICE 'PASA';
> >
> > > LOOP
> >
> > > FETCH dw0_0010_1_c INTO dw10;
> >
> > > EXIT WHEN NOT FOUND;
> >
> > > RAISE NOTICE 'prueba', dw10.tiempo;
> >
> > > END LOOP;
> >
> > >
> >
> > > RAISE NOTICE 'PASA FIN';
> >
> > >
> >
> > > RETURN 0;
> >
> > > END;
> >
> > > $BODY$
> >
> > > LANGUAGE 'plpgsql' VOLATILE
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > > __________ Information from ESET NOD32 Antivirus,
> > version of virus signature
> > > database 3146 (20080530) __________
> >
> > >
> >
> > > The message was checked by ESET NOD32 Antivirus.
> >
> > >
> >
> > > http://www.eset.com
> > >
> >
> > >
> >
> > > --
> >
> > > TIP 1: para suscribirte y desuscribirte, visita
> http://archives.postgresql.org/pgsql-es-ayuda
> > >
> >
> >
> >
> > Estimado :
> >
> > Con que envio el correo solo una vez basta, ha llegado tres veces,
> >
> > creo que si existe alguien de la lista que pueda respondder a tu duda
> >
> > lo hara lo mas rapido posible, saludos.
> >
> > J
> >
> > --
> >
> > ----------------------
> >
> > Slds.
> >
> > jchavez
> >
> > linux User #397972 on http://counter.li.org/
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> Para dar de baja la suscripción, mande un mensaje a:
> opensuse-es+unsubscribe@opensuse.org
> Para obtener el resto de direcciones-comando, mande
> un mensaje a:
> opensuse-es+help@opensuse.org
>
>

--
TIP 4: No hagas 'kill -9' a postmaster

[pgsql-es-ayuda] Postgres y standard PCI

Hola!
La empresa para la cual trabajo ahora esta comenzando a usar Postgres despues de 9 meses de pleitos con todo el mundo quite a MSSQL y puse a Postgres por encima de todos ,jejeje.
Bueno, el caso es que ahora se estan certificando en lo que es el standard PCI . Esto es un standrad para las empresas que manejan transaccuies online y alamcenan numeros de tarjetas de credito e informacion sensitiva..
Me han preguntado que si podemos hacer esto en Postgres , mantener ciertas informaciones encriptadas ya que el standard lo exige.
Nunca he trabajado con encriptaciones a ese nivel porque siempre le dejaba eso al sistema operativo pero ahora me veo en la necesidad de empezar y quiero preguntar que tipo de encriptacion usan postgres para esto.
Se que es pgcrypto pero sera una encriptacion seria, digamos AES, DES u otro, o son solo algoritmos simples para casos no muy exigentes?
Este es un buen ejercicio ya que de lograrlo podemos tambien presumir de el usando Postgres.
*-------------------------------------------------------*
*-Edwin Quijada
*-Developer DataBase
*-JQ Microsistemas
*-809-849-8087

* " Si deseas lograr cosas excepcionales debes de hacer cosas fuera de lo comun"
*-------------------------------------------------------*

_________________________________________________________________
Get your fix of news, sports, entertainment and more on MSN Mobile
http://www.msnmobilefix.com/Default.aspx--
TIP 1: para suscribirte y desuscribirte, visita http://archives.postgresql.org/pgsql-es-ayuda

Re: [GENERAL] The optimizer is too smart for me - How can I trick it?

On Fri, May 30, 2008 at 10:49:21AM +0200, Peter Vanderborght wrote:
> What can I do to tell the optimizer to keep its hands off my query or at
> least get it to not optimize?

The usual trick is you put an OFFSET 0 in the subquery, which prevents
the optimiser from pulling it up.

Have a nice day.
--
Martijn van Oosterhout <kleptog@svana.org>

http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Re: [SQL] Weeks elapsed to Months elapsed conversion

>
> Hi all,
> I have a simple question (tried googling but found no
> answers). How do I convert weeks elapsed into months elapsed?
> I have data that contains duration in weeks (without any
> other date values such as year and so on) for example a week
> value of 14 and I would like to convert the 14 weeks to 3
> months (some lose of accuracy expected).
> Expected tests may be:
> 14 weeks yields 3 months.
> 1 weeks yields 0 months.
>

If accuracy isnt a issue probably floor() could suite you:

months=select floor(weeks/4);

Regards,
Fernando.


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[pgus-board] bylaws: make email notification of meetings the default, members special request notification by mail

Section 6. Notice.
* make email notification of meetings the default, members special
request notification by mail

Can we make this change please?

Suggested by Magnus Hagander, and I agree.

--
Selena Deckelmann
United States PostgreSQL Association - http://www.postgresql.us
PDXPUG - http://pugs.postgresql.org/pdx
Me - http://www.chesnok.com/daily

--
Sent via pgus-board mailing list (pgus-board@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgus-board

Re: [HACKERS] Core team statement on replication in PostgreSQL

On Fri, 2008-05-30 at 11:30 -0400, Andrew Dunstan wrote:
>
> Tom Lane wrote:
> > Simon Riggs <simon@2ndquadrant.com> writes:
> >
> >> On Fri, 2008-05-30 at 12:31 +0530, Gurjeet Singh wrote:
> >>
> >>> On Fri, May 30, 2008 at 10:40 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >>>
> >>>> But since you mention it: one of the plausible answers for fixing the
> >>>> vacuum problem for read-only slaves is to have the slaves push an xmin
> >>>> back upstream to the master to prevent premature vacuuming.
> >>>>
> >>> I think it would be best to not make the slave interfere with the
> >>> master's operations; that's only going to increase the operational
> >>> complexity of such a solution.
> >>>
> >> We ruled that out as the-only-solution a while back. It does have the
> >> beauty of simplicity, so it may exist as an option or possibly the only
> >> way, for 8.4.
> >>
> > Yeah. The point is that it's fairly clear that we could make that work.
> > A solution that doesn't impact the master at all would be nicer, but
> > it's not at all clear to me that one is possible, unless we abandon
> > WAL-shipping as the base technology.
> >
> Quite. Before we start ruling things out let's know what we think we can
> actually do.

Let me re-phrase: I'm aware of that possibility and believe we can and
could do it for 8.4. My assessment is that people won't find it
sufficient and I am looking at other alternatives also. There may be a
better one possible for 8.4, there may not. Hence I've said "something
in 8.4, something better later". There is no need to decide that is the
only way forward, yet.

I hope and expect to put some of these ideas into a more concrete form,
but this has not yet happened. Nothing has slipped, not having any
trouble getting on with it, just that my plans were to not start it yet.
I think having a detailed design ready for review by September commit
fest is credible.

> I hope that NTT will release their code ASAP so we will have a better
> idea of what we have and what we need.

That has very little to do with Hot Standby, though there could be patch
conflicts, which is why I'm aiming to get WAL streaming done first.

--
Simon Riggs

www.2ndQuadrant.com

PostgreSQL Training, Services and Support


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[GENERAL] syntax error with execute

I have a query like this in a plpgsql function:

EXECUTE 'INSERT INTO '||tablename||' ('||fields||') VALUES
('||vals||') RETURNING currval('''||seqname||''') INTO newid'

and I get the response:

ERROR: syntax error at or near "INTO"
LINE 1: ...','2008','4',NULL) RETURNING currval('id_seq') INTO newid

And I do not understand this error. If I take the INSERT command and
run it by hand, it works fine, but it doesn't work in the function
when called by execute. Anybody has an idea on what is wrong and what
to do about it?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [pgsql-es-ayuda] pl/pgsql para torpes

On Fri, May 30, 2008 at 12:09 PM, Juan Carlos Barranco de Paz
<jcb@greccosoft.es> wrote:
>
> Hola, estoy empezando a trabajar con pl/pgsql y no entiendo bien el uso de
> las comillas y del raise, por favor me podeis decir como hacer esto o que
> estoy haciendo mal y un donde puedo conseguir un manual paras torpes de
> pl/pgsql.
>
> Cuando ejecuto select dw0_0010() me devuelve este error :
> ERROR: too many parameters specified for RAISE
> CONTEXT: PL/pgSQL function "dw0_0010_1" line 6 at raise sentencia SQL:
> «SELECT dw0_0010_1( $1 )» PL/pgSQL function "dw0_0010" line 13 at perform
>
> ********** Error **********
>
> ERROR: too many parameters specified for RAISE Estado SQL:42601
> Contexto:PL/pgSQL function "dw0_0010_1" line 6 at raise sentencia SQL:
> «SELECT dw0_0010_1( $1 )» PL/pgSQL function "dw0_0010" line 13 at perform
>
>
> Estas son las funciónes :
>
> CREATE OR REPLACE FUNCTION dw0_0010()
> RETURNS smallint AS
> $BODY$
> DECLARE
> dw01 dw01conf%ROWTYPE;
> dw0_0010_c cursor for select * from dw01conf;
> BEGIN
> OPEN dw0_0010_c ;
> LOOP
> FETCH dw0_0010_c INTO dw01;
> EXIT WHEN NOT FOUND;
> PERFORM dw0_0010_1(dw01);
> END LOOP;
> CLOSE dw0_0010_c;
> RETURN 0;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
>
> ------ Hasta aqui creo que va bien pero esta me falla por todos lados
>
> CREATE OR REPLACE FUNCTION dw0_0010_1(dw01 dw01conf)
> RETURNS smallint AS
> $BODY$
> DECLARE
> aux0 text;
> dw10 dw10tcom%ROWTYPE;
> dw0_0010_1_c refcursor;
> BEGIN
> RAISE NOTICE 'texto1', dw01.empresa;
>
> if dw01.origen = 1 or dw01.origen = 3
> then
> aux0 := 'select distinct
> c.empresa,to_number(to_char(c.fecha,''YYYYMMDDHH24''),''9999999999''),
> to_number(to_char(c.fecha,''YYYY''),''9999''),
> to_number(to_char(c.fecha,''Q''),''9''),
> to_number(to_char(c.fecha,''MM''),''99''),
> to_number(to_char(c.fecha,''W''),''9''),
> to_number(to_char(c.fecha,''WW''),''99''),
> to_number(to_char(c.fecha,''ID''),''9''),
> to_number(to_char(c.fecha,''DD''),''99'')
> from gc05albc c,gc06albl l
> where c.empresa = ''' || dw01.empresa || '''
> and c.serie = l.serie
> and c.albaran = l.albaran
> and c.fecha >=''' || dw01.fecha_inicial
> || '''
> and c.proveedor = l.proveedor
> and l.tipo = 1
> and l.unidades <> 0
> and length(l.articulo) = 0';
> end if;
>
> OPEN dw0_0010_1_c FOR EXECUTE aux0;
>
> RAISE NOTICE 'PASA';
> LOOP
> FETCH dw0_0010_1_c INTO dw10;
> EXIT WHEN NOT FOUND;
> RAISE NOTICE 'prueba', dw10.tiempo;
> END LOOP;
>
> RAISE NOTICE 'PASA FIN';
>
> RETURN 0;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature
> database 3146 (20080530) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
> --
> TIP 1: para suscribirte y desuscribirte, visita http://archives.postgresql.org/pgsql-es-ayuda
>

Estimado :
Con que envio el correo solo una vez basta, ha llegado tres veces,
creo que si existe alguien de la lista que pueda respondder a tu duda
lo hara lo mas rapido posible, saludos.
J
--
----------------------
Slds.
jchavez
linux User #397972 on http://counter.li.org/
--
TIP 1: para suscribirte y desuscribirte, visita http://archives.postgresql.org/pgsql-es-ayuda

[GENERAL] Query planning configuration and solid state drives

What should be changed in the query planning configuration, if at all,
if a ultrafast solid state drive would be used to host a whole
database ? Specially if used in Raid 0 configurations.

Regards, Clodoaldo Pinto Neto

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [pgsql-es-ayuda] pl/pgsql para torpes

El problema radica en la linea:

      RAISE NOTICE 'prueba', dw10.tiempo;

Para que el RAISE NOTICE refleje variables del plpgsql tienes que introducir el simbolo % por cada variable que quieres que contemple.

Un ejemplo:

      RAISE NOTICE 'valor de la variable1: % | valor de la variable2: % ',variable1, variable2;

--
Atte. José Ruiz Aguilera.

Re: [HACKERS] Sugestion: xpath

marcoduarte@bndes.gov.br writes:
> I think it is good idea make a function returning set of records,
> like xpath_table, but accepting xml data in a text paramiter.
> Today if you have a function with a xml parameter, you have to save it in
> a table to use xpath.

I believe you're mistaken. Why would you need to put the value into
a table?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Core team statement on replication in PostgreSQL

Tom Lane wrote:
> Simon Riggs <simon@2ndquadrant.com> writes:
>
>> On Fri, 2008-05-30 at 12:31 +0530, Gurjeet Singh wrote:
>>
>>> On Fri, May 30, 2008 at 10:40 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>>
>>>> But since you mention it: one of the plausible answers for fixing the
>>>> vacuum problem for read-only slaves is to have the slaves push an xmin
>>>> back upstream to the master to prevent premature vacuuming.
>>>>
>>> I think it would be best to not make the slave interfere with the
>>> master's operations; that's only going to increase the operational
>>> complexity of such a solution.
>>>
>
>
>> We ruled that out as the-only-solution a while back. It does have the
>> beauty of simplicity, so it may exist as an option or possibly the only
>> way, for 8.4.
>>
>
> Yeah. The point is that it's fairly clear that we could make that work.
> A solution that doesn't impact the master at all would be nicer, but
> it's not at all clear to me that one is possible, unless we abandon
> WAL-shipping as the base technology.
>
>
>

Quite. Before we start ruling things out let's know what we think we can
actually do.

I hope that NTT will release their code ASAP so we will have a better
idea of what we have and what we need.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [GENERAL] The optimizer is too smart for me - How can I trick it?

GREAT!!!
Just "offset 0" in the subquery did the trick!

I had already been playing with a stored proc, but that's way more messy
than this.

Thanks a million!
Peter

-----Original Message-----
From: Adam Rich [mailto:adam.r@sbcglobal.net]
Sent: 30 May 2008 17:14
To: peter.vanderborght@taatu.com; pgsql-general@postgresql.org
Subject: RE: [GENERAL] The optimizer is too smart for me - How can I trick
it?


> I've implemented Depesz's running total function
> (http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-
> sum-in-
> one-query/) in my DB, which works great.
> Now what I want to do is get the running total for a certain statement
> and then do a subselect on that result so to get a non-zero start on a
> function.
>
> Instead, the optimizer sees what I'm trying to do, moves the where
> clause inside the subquery and my output becomes
>
> What can I do to tell the optimizer to keep its hands off my query or
> at least get it to not optimize?
>

I think if you add a LIMIT/OFFSET clause to your subquery, the planner
will leave it alone.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [SQL] Weeks elapsed to Months elapsed conversion

Allan Kamau wrote:
> Hi all,
> I have a simple question (tried googling but found no answers). How do I
> convert weeks elapsed into months elapsed?
> I have data that contains duration in weeks (without any other date
> values such as year and so on) for example a week value of 14 and I
> would like to convert the 14 weeks to 3 months (some lose of accuracy
> expected).
> Expected tests may be:
> 14 weeks yields 3 months.
> 1 weeks yields 0 months.

Are these stored as intervals?

=> SELECT extract(month from justify_days('14 weeks'::interval));
date_part
-----------
3
(1 row)

=> SELECT extract(month from justify_days('1 week'::interval));
date_part
-----------
0
(1 row)

If you just have a number (e.g. 14) then you can just do something like:

=> SELECT round(14 * 7 / 30);
round
-------
3
(1 row)


--
Richard Huxton
Archonet Ltd

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Re: [GENERAL] The optimizer is too smart for me - How can I trick it?

> I've implemented Depesz's running total function
> (http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-
> sum-in-
> one-query/) in my DB, which works great.
> Now what I want to do is get the running total for a certain statement
> and
> then do a subselect on that result so to get a non-zero start on a
> function.
>
> Instead, the optimizer sees what I'm trying to do, moves the where
> clause
> inside the subquery and my output becomes
>
> What can I do to tell the optimizer to keep its hands off my query or
> at
> least get it to not optimize?
>

I think if you add a LIMIT/OFFSET clause to your subquery, the planner
will leave it alone.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Joshua D. Drake wrote:
> Jon Lapham wrote:
>> How are we, Joe PostgreSQL users on the street, supposed to know which
>> instructions to follow? Have I (very possible) missed some official
>
> That would be a question for mediawiki people not PostgreSQL people.

Okay, makes sense. It just seemed to me that in previous upgrades I
have done, the mediawiki people complained that these problems were due
to changes made in postgresql's tsearch2 setup.

Also, a lot of the instructions do seem to be very postgres-oriented
(for example: hand editting of the pgdump output, etc), not much to do
on the mediawiki side of things. Other apps besides mediawiki seem to
have similar problems, or maybe a better word is upgrade complications.

>> PostgreSQL instructions? How do we go about triaging tsearch2 problems?
>>
>
> You could start by giving us PostgreSQL output, not mediawiki output. Up
> your logging level in the postgresql.conf, reload, and give us a little
> more context.

Okay, I'll work on that.

> Here are the docs on Tsearch:
>
> http://www.postgresql.org/docs/8.3/static/textsearch.html
>
> Which is decidedly different from 8.2 to 8.3.
>
> Here are the docs on logging:
>
> http://www.postgresql.org/docs/8.3/static/runtime-config-logging.html

Thanks.

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
Jon Lapham <lapham@jandr.org> Rio de Janeiro, Brasil
Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Jon Lapham wrote:
> Hello all,
>
> I'm sure I did something wrong during my upgrade of mediawiki from
> Postgresql 8.2 to 8.3. Any help on how to recover would be appreciated.

[...]

> I would like to say thanks to the people that put in so much time and
> effort in developing tsearch2 (and postgresql too), your work is greatly
> appreciated. However, I have never had a recent postgresql upgrade work
> seemlessly, and it is almost always due to issues with tsearch2. :(

yeah - upgrades with tsearch2 have always been a bit of a problem - this
is one of many reasons why tsearch2 got fully integrated into the
backend starting with 8.3.

>
> While searching the internet for magic recipes on how to perform these
> upgrades that involve tsearch2, I find long complex instruction sets
> detailing brain-numbingly complex operations (hand edit the schema!):
>
> http://julien.danjou.info/blog/index.php/post/2008/05/19/Upgrading-mediawiki-from-PostgreSQL-82-to-83

>
>
> Also, I have found this blog entry from Greg Mullane which makes it all
> seem so simple: (Note Tom Lane's comment, which seems to directly relate
> to the error message I am seeing).
>
> http://people.planetpostgresql.org/greg/index.php?/archives/123-MediaWiki-is-Postgres-8.3-compatible.html

>
>
> These are just a 2 examples, there are others. The one common thread
> shared by all the instructions are that they say different things. How
> are we, Joe PostgreSQL users on the street, supposed to know which
> instructions to follow? Have I (very possible) missed some official
> PostgreSQL instructions? How do we go about triaging tsearch2 problems?

http://www.postgresql.org/docs/8.3/static/textsearch-migration.html has
a some discussion - and also see the backwards compatibility module
provided in contrib/tsearch2.


Stefan

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Tom Lane wrote:
> Jon Lapham <lapham@jandr.org> writes:
>> Have I (very possible) missed some official
>> PostgreSQL instructions?
>
> http://www.postgresql.org/docs/8.3/static/textsearch-migration.html
> http://www.postgresql.org/docs/8.3/static/tsearch2.html
>
> I haven't personally tried that procedure with MediaWiki, though.

Okay, thanks for the pointer. I don't know, it just makes my head hurt
to read all the documentation on tsearch2. I guess I am just not smart
enough to figure this out.

Just a random examples from the textsearch-migration page:

-Text search configuration setup is completely different now...There is
not currently any automated support for converting an existing custom
configuration for 8.3; you're on your own here. Ouch!

-In thesaurus configuration files, stop words must be marked with ?." I
don't know what any of that means, and to be honest with you, I don't
want to know.

Okay, I'll go back and re-read all this and try to figure it out.

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
Jon Lapham <lapham@jandr.org> Rio de Janeiro, Brasil
Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Jon Lapham <lapham@jandr.org> writes:
> My mediawiki pages are loading, but when I try to edit them, I get this
> error message:

> A database error has occurred Query: INSERT INTO pagecontent
> (old_id,old_text,old_flags) VALUES [snip] ERROR: text search
> configuration "default" does not exist CONTEXT: PL/pgSQL function
> "ts2_page_text" line 3 at assignment

There isn't a "default" configuration in 8.3, unless you make one named
that.

> These are just a 2 examples, there are others. The one common thread
> shared by all the instructions are that they say different things. How
> are we, Joe PostgreSQL users on the street, supposed to know which
> instructions to follow? Have I (very possible) missed some official
> PostgreSQL instructions?

http://www.postgresql.org/docs/8.3/static/textsearch-migration.html
http://www.postgresql.org/docs/8.3/static/tsearch2.html

I haven't personally tried that procedure with MediaWiki, though.

regards, tom lane

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [SQL] Weeks elapsed to Months elapsed conversion

Approx. 52 weeks in a year, thus 13 weeks in 3 months.
 
select numberofweeks/13*3 as numberofmonths
from yourtable
 
or if you want whole months returned
select floor(numberofweeks/13*3) as numberofmonths
from yourtable

>>> Allan Kamau <allank@sanbi.ac.za> 2008-05-30 11:21 >>>
Hi all,
I have a simple question (tried googling but found no answers). How do I
convert weeks elapsed into months elapsed?
I have data that contains duration in weeks (without any other date
values such as year and so on) for example a week value of 14 and I
would like to convert the 14 weeks to 3 months (some lose of accuracy
expected).
Expected tests may be:
14 weeks yields 3 months.
1 weeks yields 0 months.

Is there such a function. The rudimentary solution (may reduce lose of
accuracy) am thinking of is to add the weeks to the value returned by
clock_timestamp() then subtract clock_timestamp() from it. The question
now is how to convert the returned value to months elapsed as opposed to
days elapsed.

Allan.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[Fwd: Re: [planet] Can I have my feed shown on planetpostgresql.org?]

Any objections?

-------- Forwarded Message --------
> From: Kenny Gorman <kgorman@kennygorman.com>
> To: Devrim GÜNDÜZ <devrim@gunduz.org>
> Cc: Kenny Gorman <kgorman@kennygorman.com>, planet@postgresql.org
> Subject: Re: [planet] Can I have my feed shown on
> planetpostgresql.org?
> Date: Fri, 30 May 2008 02:44:58 -0700
>
> Devrim,
>
> Sure, here you go, I think this works..
>
> http://www.kennygorman.com/wordpress/?cat=7&feed=atom
>
> -kg
>
> On May 30, 2008, at 12:41 AM, Devrim GÜNDÜZ wrote:
>
> >
> > Hi,
> >
> > Do you have a specific category for PostgreSQL, which includes all
> > PostgreSQL related stuff? I'd like to pull that one instead of whole
> > feed.
> >
> > Regards, Devrim
> >
> > On Wed, 28 May 2008, Kenny Gorman wrote:
> >
> >> I generally blog about PostgreSQL, Slony, Oracle, python,
> >> scalability and other fun DB related stuff, I work at www.hi5.com


> >> where we do some fun stuff with PostgreSQL.
> >>
> >> site:
> >>
> >> www.kennygorman.com
> >>
> >> feed:
> >>
> >> http://www.kennygorman.com/wordpress/?feed=atom
> >>
> >
> > --
> > Devrim GÜNDÜZ
> > RHCE, PostgreSQL Consultant @ Command Prompt, Inc.
> >

http://www.CommandPrompt.com
> > devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
> >

http://www.gunduz.org
>
>
--
Devrim GÜNDÜZ , RHCE
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/

Re: [GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Jon Lapham wrote:
> Hello all,

> My mediawiki pages are loading, but when I try to edit them, I get this
> error message:
>
> A database error has occurred Query: INSERT INTO pagecontent
> (old_id,old_text,old_flags) VALUES [snip] ERROR: text search
> configuration "default" does not exist CONTEXT: PL/pgSQL function
> "ts2_page_text" line 3 at assignment


>
> These are just a 2 examples, there are others. The one common thread
> shared by all the instructions are that they say different things. How
> are we, Joe PostgreSQL users on the street, supposed to know which
> instructions to follow? Have I (very possible) missed some official

That would be a question for mediawiki people not PostgreSQL people.

> PostgreSQL instructions? How do we go about triaging tsearch2 problems?
>

You could start by giving us PostgreSQL output, not mediawiki output. Up
your logging level in the postgresql.conf, reload, and give us a little
more context.

Here are the docs on Tsearch:

http://www.postgresql.org/docs/8.3/static/textsearch.html

Which is decidedly different from 8.2 to 8.3.

Here are the docs on logging:

http://www.postgresql.org/docs/8.3/static/runtime-config-logging.html

Sincerely,

Joshua D. Drake


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[austinpug] June meeting

The June meeting will be at Sun, Tuesday June 3rd at 7PM.

Food: do we want to do Mangia's again? Other suggestions?

Presentation: we identified 3 possibilities; GUCs / tuning, dtrace,
and internals. I'll also throw out doing an overview of PGCon, since
there were 3 of us there. What would folks like to see?

(Robert, please get me that internals presentation :) )

Also, I want to avoid turning this into the Decibel & Robert show.
It's bad for the user group if it's existence hinges on only one or
two people. So, I'd like to see someone besides us present at least
every other month. This could be as simple as describing how you're
using Postgres, and any problems you're running into (read as: free
consulting!). So please be thinking about what you could present; I'd
like to put someone down for the July meeting at the June meeting.

Also, I think it would be good to start doing a general Q&A at the
meetings, so please think of any Postgres related questions you've
been wondering about and haven't had the chance to ask yet.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

[GENERAL] Mediawiki 1.10 and PG 8.3 upgrade

Hello all,

I'm sure I did something wrong during my upgrade of mediawiki from
Postgresql 8.2 to 8.3. Any help on how to recover would be appreciated.

Possible useful info:
OS: Fedora 9
Postgresql: PostgreSQL 8.3.1 on x86_64-redhat-linux-gnu
Mediaiwiki: mediawiki-1.10.4-39.fc9.x86_64

My mediawiki pages are loading, but when I try to edit them, I get this
error message:

A database error has occurred Query: INSERT INTO pagecontent
(old_id,old_text,old_flags) VALUES [snip] ERROR: text search
configuration "default" does not exist CONTEXT: PL/pgSQL function
"ts2_page_text" line 3 at assignment

Backtrace:

#0 /usr/share/mediawiki/includes/Database.php(761):
DatabasePostgres->reportQueryError('ERROR: text se...', 1, 'INSERT INTO
pag...', 'Revision::inser...', 0)
#1 /usr/share/mediawiki/includes/DatabasePostgres.php(695):
Database->query('INSERT INTO pag...', 'Revision::inser...', 0)
#2 /usr/share/mediawiki/includes/Revision.php(696):
DatabasePostgres->insert('text', Array, 'Revision::inser...')
#3 /usr/share/mediawiki/includes/Article.php(1336):
Revision->insertOn(Object(DatabasePostgres))
#4 /usr/share/mediawiki/includes/Article.php(1205): Article->doEdit('{|
class="wikit...', '', 98)
#5 /usr/share/mediawiki/includes/EditPage.php(865):
Article->updateArticle('{| class="wikit...', '', false, false, '', '')
#6 /usr/share/mediawiki/includes/EditPage.php(426): EditPage->attemptSave()
#7 /usr/share/mediawiki/includes/EditPage.php(279): EditPage->edit()
#8 /usr/share/mediawiki/includes/Wiki.php(432): EditPage->submit()
#9 /usr/share/mediawiki/includes/Wiki.php(48):
MediaWiki->performAction(Object(OutputPage), Object(Article),
Object(Title), Object(User), Object(WebRequest))
#10 /usr/share/mediawiki/index.php(92):
MediaWiki->initialize(Object(Title), Object(OutputPage), Object(User),
Object(WebRequest))
#11 {main}

I would like to say thanks to the people that put in so much time and
effort in developing tsearch2 (and postgresql too), your work is greatly
appreciated. However, I have never had a recent postgresql upgrade work
seemlessly, and it is almost always due to issues with tsearch2. :(

While searching the internet for magic recipes on how to perform these
upgrades that involve tsearch2, I find long complex instruction sets
detailing brain-numbingly complex operations (hand edit the schema!):

http://julien.danjou.info/blog/index.php/post/2008/05/19/Upgrading-mediawiki-from-PostgreSQL-82-to-83

Also, I have found this blog entry from Greg Mullane which makes it all
seem so simple: (Note Tom Lane's comment, which seems to directly relate
to the error message I am seeing).

http://people.planetpostgresql.org/greg/index.php?/archives/123-MediaWiki-is-Postgres-8.3-compatible.html

These are just a 2 examples, there are others. The one common thread
shared by all the instructions are that they say different things. How
are we, Joe PostgreSQL users on the street, supposed to know which
instructions to follow? Have I (very possible) missed some official
PostgreSQL instructions? How do we go about triaging tsearch2 problems?

--
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
Jon Lapham <lapham@jandr.org> Rio de Janeiro, Brasil
Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Core team statement on replication in PostgreSQL

On 5/30/08, Gurjeet Singh <singh.gurjeet@gmail.com> wrote:
> On Fri, May 30, 2008 at 10:40 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > But since you mention it: one of the plausible answers for fixing the
> > vacuum problem for read-only slaves is to have the slaves push an xmin
> > back upstream to the master to prevent premature vacuuming. The current
> > design of pg_standby is utterly incapable of handling that requirement.
> > So there might be an implementation dependency there, depending on how
> > we want to solve that problem.
>
> I think it would be best to not make the slave interfere with the master's
> operations; that's only going to increase the operational complexity of such
> a solution.

I disagree - it's better to consider syncronized WAL-slaves
as equal to master, so having queries there affect master is ok.

You need to remeber this solution tries not to replace 100-node Slony-I
setups. You can run sanity checks on slaves or use them to load-balance
read-only OLTP queries, but not random stuff.

> There could be multiple slaves following a master, some serving
> data-warehousing queries, some for load-balancing reads, some others just
> for disaster recovery, and then some just to mitigate human errors by
> re-applying the logs with a delay.

To run warehousing queries you better use Slony-I / Londiste. For
warehousring you want different / more indexes on tables anyway,
so I think it's quite ok to say "don't do it" for complex queries
on WAL-slaves.

> I don't think any one installation would see all of the above mentioned
> scenarios, but we need to take care of multiple slaves operating off of a
> single master; something similar to cascaded Slony-I.

Again, the synchronized WAL replication is not generic solution.
Use Slony/Londiste if you want to get totally independent slaves.

Thankfully the -core has set concrete and limited goals,
that means it is possible to see working code in reasonable time.
I think that should apply to read-only slaves too.

If we try to make it handle any load, it will not be finished in any time.

Now if we limit the scope I've seen 2 variants thus far:

1) Keep slave max in sync, let the load there affect master (xmin).
- Slave can be used to load-balance OLTP load
- Slave should not be used for complex queries.

2) If long query is running, let slave lag (avoid applying WAL data).
- Slave cannot be used to load-balance OLTP load
- Slave can be used for complex queries (although no new indexes
or temp tables can be created).

I think 1) is more important (and more easily implementable) case.

For 2) we already have solutions (Slony/Londiste/Bucardo, etc)
so there is no point to make effort to solve this here.

--
marko

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: [HACKERS] Core team statement on replication in PostgreSQL

On Thu, May 29, 2008 at 01:58:34PM -0700, David Fetter wrote:

> If people on core had come to the idea that we needed to build in
> replication *before* 8.3 came out, they certainly didn't announce it.
>
> Now is a great time to mention this because it gives everybody time to:
>
> 1. Come to a consensus on what the out-of-the-box replication should
> be, and
>
> 2. Build, test and debug whatever the consensus out-of-the-box
> replication turns out to be.

None of that is an argument for why this has to go in 8.4.

I argued in Ottawa that the idea that you have to plan a feature for
_the next release_ is getting less tenable with each release. This is
because major new features for Postgres are now often big and
complicated. The days of big gains from single victories are mostly
over (though there are exceptions, like HOT). Postgres is already
mature. As for the middle-aged person with a mortgage, longer-term
planning is simply a necessary part of life now.

There are two possibilities here. One is to have huge releases on
much longer timetables. I think this is unsustainable in a free
project, because people will get bored and go away if they don't get
to use the results of their work in a reasonably short time frame.
The other is to accept that sometimes, planning and development for
new features will have to start a long time before actual release --
maybe planning and some coding for 2 releases out. That allows large
features like the one we're discussing to be developed responsibly
without making everything else wait for it.

A

--
Andrew Sullivan
ajs@commandprompt.com
+1 503 667 4564 x104
http://www.commandprompt.com/

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[HACKERS] Sugestion: xpath


        I think it is good idea make a function returning set of records, like xpath_table, but accepting xml data in a text paramiter.
Today if you have a function with a xml parameter, you have to save it in a table to use xpath.

Thanks,

[GENERAL] Connection problem

I get a lot of
Error server closed the connection unexpectedly This probably means
the server terminated abnormally before or while processing the
request.

and I think I need some help finding out what is the problem. Any
suggestions on where to start? I think I have maximum logging on
(debug5) but prior to the crash I get no log. I connect to the server
with php/apache and I use pg_pconnect to get persistent connections.

The first log message for a working request to the server says:

LOG: 00000: connection received: host=[local]
LOCATION: BackendInitialize, postmaster.c:2755
DEBUG: 00000: forked new backend, pid=6961 socket=8
LOCATION: BackendStartup, postmaster.c:2581
DEBUG: 00000: received password packet
LOCATION: recv_password_packet, auth.c:940
LOG: 00000: connection authorized: user=myuser database=mydb
LOCATION: BackendInitialize, postmaster.c:2825
DEBUG: 00000: postmaster child[6961]: starting with (
LOCATION: BackendRun, postmaster.c:2925
DEBUG: 00000: postgres
LOCATION: BackendRun, postmaster.c:2928
DEBUG: 00000: -v196608
LOCATION: BackendRun, postmaster.c:2928
DEBUG: 00000: -y
LOCATION: BackendRun, postmaster.c:2928
DEBUG: 00000: mydb
LOCATION: BackendRun, postmaster.c:2928
DEBUG: 00000: )
LOCATION: BackendRun, postmaster.c:2930
DEBUG: 00000: InitPostgres
LOCATION: PostgresMain, postgres.c:3142
DEBUG: 00000: StartTransaction
LOCATION: ShowTransactionState, xact.c:4001
DEBUG: 00000: name: unnamed; blockState: DEFAULT; state:
INPROGR, xid/subid/cid: 8513010/1/0, nestlvl: 1, children: <>
LOCATION: ShowTransactionStateRec, xact.c:4026
DEBUG: 00000: CommitTransaction
LOCATION: ShowTransactionState, xact.c:4001
DEBUG: 00000: name: unnamed; blockState: STARTED; state:
INPROGR, xid/subid/cid: 8513010/1/0, nestlvl: 1, children: <>
LOCATION: ShowTransactionStateRec, xact.c:4026
DEBUG: 00000: StartTransactionCommand
LOCATION: start_xact_command, postgres.c:2200
STATEMENT: SELECT count(*) FROM Users
DEBUG: 00000: StartTransaction
LOCATION: ShowTransactionState, xact.c:4001

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Avoiding second heap scan in VACUUM

On Fri, May 30, 2008 at 3:31 PM, Simon Riggs <simon@2ndquadrant.com> wrote:
>
>
> Perhaps we can start first scan, check xid after we scan each few
> blocks. Once we find the xid is older, then we know the size of the
> second scan can be limited to only those blocks already scanned. So the
> two endpoints of behaviour are we skip the scan completely or we do the
> whole scan, but at least there is a saving in many cases without
> waiting.
>

Hmm. Interesting. I was about to suggest that we use some heuristic
such as size of the table to decide whether or not try the
optimization. But what you just suggested makes more sense. So instead
of waiting, we anyways start the first scan. If we are lucky, in some
time all the old transactions would go away and then we can start
marking the DEAD line pointers as DEAD_RECLAIMED. The second pass just
needs to rescan the initial blocks to remove the DEAD line pointers.

Thanks,
Pavan

--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[pgsql-es-ayuda] pl/pgsql para torpes

Hola, estoy empezando a trabajar con pl/pgsql y no entiendo bien el uso de
las comillas y del raise, por favor me podeis decir como hacer esto o que
estoy haciendo mal y un donde puedo conseguir un manual paras torpes de
pl/pgsql.

Cuando ejecuto select dw0_0010() me devuelve este error :
ERROR: too many parameters specified for RAISE
CONTEXT: PL/pgSQL function "dw0_0010_1" line 6 at raise sentencia SQL:
«SELECT dw0_0010_1( $1 )» PL/pgSQL function "dw0_0010" line 13 at perform

********** Error **********

ERROR: too many parameters specified for RAISE Estado SQL:42601
Contexto:PL/pgSQL function "dw0_0010_1" line 6 at raise sentencia SQL:
«SELECT dw0_0010_1( $1 )» PL/pgSQL function "dw0_0010" line 13 at perform


Estas son las funciónes :

CREATE OR REPLACE FUNCTION dw0_0010()
RETURNS smallint AS
$BODY$
DECLARE
dw01 dw01conf%ROWTYPE;
dw0_0010_c cursor for select * from dw01conf;
BEGIN
OPEN dw0_0010_c ;
LOOP
FETCH dw0_0010_c INTO dw01;
EXIT WHEN NOT FOUND;
PERFORM dw0_0010_1(dw01);
END LOOP;
CLOSE dw0_0010_c;
RETURN 0;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

------ Hasta aqui creo que va bien pero esta me falla por todos lados

CREATE OR REPLACE FUNCTION dw0_0010_1(dw01 dw01conf)
RETURNS smallint AS
$BODY$
DECLARE
aux0 text;
dw10 dw10tcom%ROWTYPE;
dw0_0010_1_c refcursor;
BEGIN
RAISE NOTICE 'texto1', dw01.empresa;

if dw01.origen = 1 or dw01.origen = 3
then
aux0 := 'select distinct
c.empresa,to_number(to_char(c.fecha,''YYYYMMDDHH24''),''9999999999''),
to_number(to_char(c.fecha,''YYYY''),''9999''),
to_number(to_char(c.fecha,''Q''),''9''),
to_number(to_char(c.fecha,''MM''),''99''),
to_number(to_char(c.fecha,''W''),''9''),
to_number(to_char(c.fecha,''WW''),''99''),
to_number(to_char(c.fecha,''ID''),''9''),
to_number(to_char(c.fecha,''DD''),''99'')
from gc05albc c,gc06albl l
where c.empresa = ''' || dw01.empresa || '''
and c.serie = l.serie
and c.albaran = l.albaran
and c.fecha >=''' || dw01.fecha_inicial
|| '''
and c.proveedor = l.proveedor
and l.tipo = 1
and l.unidades <> 0
and length(l.articulo) = 0';
end if;

OPEN dw0_0010_1_c FOR EXECUTE aux0;

RAISE NOTICE 'PASA';
LOOP
FETCH dw0_0010_1_c INTO dw10;
EXIT WHEN NOT FOUND;
RAISE NOTICE 'prueba', dw10.tiempo;
END LOOP;

RAISE NOTICE 'PASA FIN';

RETURN 0;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE 


__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3146 (20080530) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

--
TIP 1: para suscribirte y desuscribirte, visita http://archives.postgresql.org/pgsql-es-ayuda

[pgsql-advocacy] Feedback on blog post about Replication Feature decision and its impact

Hello everyone, I was about to blog about the announcement of adding
replication to the core product but then thought I should ask for
feedback here. I moved it to advocacy (from hackers). Any thoughts would
be appreciated, thanks! --Dirk

----

Every software community has its peculiar challenges, and open source is
no exception. This post discusses the relationship between a core open
source product (PostgreSQL) and commercial offerings based on it (e.g.
EnterpriseDB).<p>

PostgreSQL is a relational database system (the most advanced open
source database in its own words); to many it is known as the other open
source database (next to MySQL). Unlike MySQL, PostgreSQL is not owned
by anyone, it is a true community project. What's more, PostgreSQL is
not based on the GPL (license) but rather on the more permissive BSD
license, which lets companies distribute the database plus enhancements
without having to contribute back their code.<p>

The core system until now does not contain support for database
replication. Naturally then, there are plenty of extensions, many of
them open source, that add these features. However, if you need
replication, it is rather cumbersome having to add some extension and
maintain it separately from the core distribution. So the pressure has
been mounting to add replication to the core product, and the core team
of seven committers finally made that decision at their recent users
conference. The <a href="

http://www.nabble.com/Core-team-statement-on-replication-in-PostgreSQL-td17537053.html">discussion
of these new features</a> is refreshingly unpolitical and focussed on
the task at hand, as to be expected of a mature open source community.<p>

<a href="http://www.enterprisedb.com/">EnterpriseDB</a> is a well-funded
database startup whose product builds on PostgreSQL. EnterpriseDB adds
many "enterprise-readiness" features to the basic PostgreSQL product,
including database replication, and much more. One might argue that it
is not in the interest of EnterpriseDB to have replication added to
PostgreSQL as it reduces the differentiation between the free community
product and the more advanced commercial offering. Why pay for
EnterpriseDB if you already get what you need from the free version?
Won't adding replication to the core product reduce EnterpriseDBs sales?
This tension seems only to get worse when you realize that EnterpriseDB
employs several of the core developers of PostgreSQL, suggesting a
direct conflict of interest when making decisions like whether to add
replication or not.<p>

So they finally made the decision to add replication, and it gives me
the opportunity to discuss what I believe are misunderstandings about
the open source business.<p>

<h3>Won't EnterpriseDB loose sales once replication is added to the core
PostgreSQL product?</h3>

I think the opposite will be the case. Officially, EnterpriseDB wants to
be a cheaper Oracle, but in the open source arena, its main competitor
is MySQL. EnterpriseDB the commercial offering is competing with MySQL
the commercial offering, and not with the free community version of
PostgreSQL. It is in EnterpriseDB's interest to have a free PostgreSQL
version installed and used in as many IT departments as possible,
because it is <a
href="http://www.riehle.org/2008/04/30/sdn-is-open-source-competing-unfairly/">the
first (and important) step to a later sale</a>, as I have discussed
elsewhere. Enhancing the free product achieves exactly this.<p>

<h3>Won't a reduced differentiation between EnterpriseDB and the core
product reduce their addressable market?</h3>

I'm pretty sure it doesn't. The addressable market size doesn't go down.
That's because EnterpriseDB is not only selling additional features, but
more importantly to many applications and customers, it is selling
"operational comfort". Operational comfort means that EnterpriseDB is
offering its throat (to choke) to customers should something go wrong.
For money obviously; this is a core part of their business. Once a
database system becomes mission-critical, few companies will want to go
without paying for support. What the reduced differentiation does,
however, is to increase the possible competition around selling such
operational comfort. Other companies may more easily enter this market
and compete with EnterpriseDB. However, as I have argued elsewhere, <a
href="http://www.riehle.org/computer-science/research/2007/computer-2007.html">by
employing core developers, EnterpriseDB is well positioned to make a
believable case that it is the go-to provider of operational comfort</a>.<p>

<h3>There is only one license, the GPL, and everyone should be using
it.</h3>

PostgreSQL is a good example of a community open source project that
does not use GPL and still is flourishing well. Whatever the ideological
background of this statement, the belief seems to be that people should
be forced to contribute back to a project rather than do so of their own
choosing. That's hardly a notion that increases freedom. More
importantly, the rationale behind it makes little sense to me. In
general, firms and individual contributors alike are motivated to
contribute back (non-differentiating) code to reduce their maintenance
overhead. If they don't, they'll only create more non-differentiating
work for themselves as they are trying to catch up with the evolving
codebase. What's more, every possible proprietary extension faces the
problem of possibly being contributed by someone else, if only there is
enough demand for it. If you wait too long to make your contribution,
someone else will do it, and you just created another maintenance and
migration problem for yourself. Which is exactly what we see happening
with the replication feature in PostgreSQL. Pressure had been mounting,
and now it will be included, to everyone's benefit.<p>


--
Into novel software paradigms, tools, processes?
Then submit a short paper to Onward! 2008 by July 2nd!
See http://www.oopsla.org/oopsla2008/cfp/cfp-onward.html
--
Phone: + 1 (650) 215 3459, Web: http://www.riehle.org

--
Sent via pgsql-advocacy mailing list (pgsql-advocacy@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-advocacy

Re: [planet] Can I have my feed shown on planetpostgresql.org?

Devrim,

Sure, here you go, I think this works..

http://www.kennygorman.com/wordpress/?cat=7&feed=atom

-kg

On May 30, 2008, at 12:41 AM, Devrim GÜNDÜZ wrote:

>
> Hi,
>
> Do you have a specific category for PostgreSQL, which includes all
> PostgreSQL related stuff? I'd like to pull that one instead of whole
> feed.
>
> Regards, Devrim
>
> On Wed, 28 May 2008, Kenny Gorman wrote:
>
>> I generally blog about PostgreSQL, Slony, Oracle, python,
>> scalability and other fun DB related stuff, I work at www.hi5.com


>> where we do some fun stuff with PostgreSQL.
>>
>> site:
>>
>> www.kennygorman.com
>>
>> feed:
>>
>> http://www.kennygorman.com/wordpress/?feed=atom
>>
>
> --
> Devrim GÜNDÜZ
> RHCE, PostgreSQL Consultant @ Command Prompt, Inc.
>

http://www.CommandPrompt.com
> devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
>

http://www.gunduz.org


--
Sent via planet mailing list (planet@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/planet

[NOVICE] How does quotes work with dynamic queries?

I have this code iin my plpgsql function

DECLARE
foo text;
begin
foo:='bar';
execute ....

and now I want to select currval() from the sequence whose name is
stored in the foo variable, with the execute command.

can I do
execute 'select currval( \'' || foo || '\')';
?

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

[GENERAL] Collate problem when using ORDER BY

Hi,

I'm new here. I work on a site that uses postgres version 8.1.5 and database encoding ISO_8859_8. When I sort select requests using order by the "weight" of the characters seem to be really funny (but consistent). It seems to me that if I create a "phantom" converted field such as:
SELECT field convert(field, "ISO_8859_8" ,"UTF8") as field_utf8 ORDER BY field_utf8;
Then the sort will be OK however, I get the error:
Query failed: ERROR: character 0xd7 of encoding "ISO_8859_8" has no equivalent in "UTF8".

Is it due to a "bad" character in the content?
Can I get rid of it like find/replace?
Can I change collate for a given table/database?
--  Regards.  David Harel,  ==================================  Home office +972 77 7657645 Fax:        +972 77 7657645 Cellular:   +972 54 4534502 Snail Mail: Amuka             D.N Merom Hagalil             13802             Israel Email:      hareldvd@ergolight-sw.com  

[SQL] Weeks elapsed to Months elapsed conversion

Hi all,
I have a simple question (tried googling but found no answers). How do I
convert weeks elapsed into months elapsed?
I have data that contains duration in weeks (without any other date
values such as year and so on) for example a week value of 14 and I
would like to convert the 14 weeks to 3 months (some lose of accuracy
expected).
Expected tests may be:
14 weeks yields 3 months.
1 weeks yields 0 months.

Is there such a function. The rudimentary solution (may reduce lose of
accuracy) am thinking of is to add the weeks to the value returned by
clock_timestamp() then subtract clock_timestamp() from it. The question
now is how to convert the returned value to months elapsed as opposed to
days elapsed.

Allan.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

[pgsql-es-ayuda] pl/pgsql para torpes

Hola, estoy empezando a trabajar con pl/pgsql y no entiendo bien el uso de
las comillas y del raise, por favor me podeis decir como hacer esto o que
estoy haciendo mal y un donde puedo conseguir un manual paras torpes de
pl/pgsql.

Cuando ejecuto select dw0_0010() me devuelve este error :
ERROR: too many parameters specified for RAISE
CONTEXT: PL/pgSQL function "dw0_0010_1" line 6 at raise
sentencia SQL: «SELECT dw0_0010_1( $1 )»
PL/pgSQL function "dw0_0010" line 13 at perform

********** Error **********

ERROR: too many parameters specified for RAISE
Estado SQL:42601
Contexto:PL/pgSQL function "dw0_0010_1" line 6 at raise
sentencia SQL: «SELECT dw0_0010_1( $1 )»
PL/pgSQL function "dw0_0010" line 13 at perform


Estas son las funciónes :

CREATE OR REPLACE FUNCTION dw0_0010()
RETURNS smallint AS
$BODY$
DECLARE
dw01 dw01conf%ROWTYPE;
dw0_0010_c cursor for select * from dw01conf;
BEGIN
OPEN dw0_0010_c ;
LOOP
FETCH dw0_0010_c INTO dw01;
EXIT WHEN NOT FOUND;
PERFORM dw0_0010_1(dw01);
END LOOP;
CLOSE dw0_0010_c;
RETURN 0;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

------ Hasta aqui creo que va bien pero esta me falla por todos lados

CREATE OR REPLACE FUNCTION dw0_0010_1(dw01 dw01conf)
RETURNS smallint AS
$BODY$
DECLARE
aux0 text;
dw10 dw10tcom%ROWTYPE;
dw0_0010_1_c refcursor;
BEGIN
RAISE NOTICE 'texto1', dw01.empresa;

if dw01.origen = 1 or dw01.origen = 3
then
aux0 := 'select distinct
c.empresa,to_number(to_char(c.fecha,''YYYYMMDDHH24''),''9999999999''),
to_number(to_char(c.fecha,''YYYY''),''9999''),
to_number(to_char(c.fecha,''Q''),''9''),
to_number(to_char(c.fecha,''MM''),''99''),
to_number(to_char(c.fecha,''W''),''9''),
to_number(to_char(c.fecha,''WW''),''99''),
to_number(to_char(c.fecha,''ID''),''9''),
to_number(to_char(c.fecha,''DD''),''99'')
from gc05albc c,gc06albl l
where c.empresa = ''' || dw01.empresa || '''
and c.serie = l.serie
and c.albaran = l.albaran
and c.fecha >=''' || dw01.fecha_inicial
|| '''
and c.proveedor = l.proveedor
and l.tipo = 1
and l.unidades <> 0
and length(l.articulo) = 0';
end if;

OPEN dw0_0010_1_c FOR EXECUTE aux0;

RAISE NOTICE 'PASA';
LOOP
FETCH dw0_0010_1_c INTO dw10;
EXIT WHEN NOT FOUND;
RAISE NOTICE 'prueba', dw10.tiempo;
END LOOP;

RAISE NOTICE 'PASA FIN';

RETURN 0;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE

__________ Information from ESET NOD32 Antivirus, version of virus signature
database 3145 (20080529) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

--
TIP 5: ¿Has leído nuestro extenso FAQ?

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

[NOVICE] need help with drop table command

I'm writing a function to drop tables until there is no table left,
but I get an error

ERROR: query has no destination for result data, It seems to be on
the line with the EXECUTE command.
Can someone help me understand this error?


CREATE OR REPLACE FUNCTION droptables() RETURNS void AS $$
DECLARE
post RECORD;
BEGIN
LOOP
FOR post IN SELECT tablename FROM pg_tables WHERE tableowner='bduser' LOOP
BEGIN
EXECUTE 'DROP TABLE '||post.tablename;
EXCEPTION WHEN OTHERS THEN
END;
END LOOP;
SELECT count(*) FROM pg_tables WHERE tableowner='bduser';
IF NOT FOUND THEN
EXIT; --avbryt om vi inte hittar fler
END IF;
END LOOP;
END;
$$ LANGUAGE plpgsql;

--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

[GENERAL] The optimizer is too smart for me - How can I trick it?

Hi,

I've implemented Depesz's running total function
(http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-sum-in-
one-query/) in my DB, which works great.
Now what I want to do is get the running total for a certain statement and
then do a subselect on that result so to get a non-zero start on a function.

Example:

select day, registrations, runningsum(cast('myregistrations' as text),
cast(registrations as int4)) as rtotal
from
(
select cast(to_char(dateinscr, 'YYYY-MM-DD') as timestamp) as day,
count(*) as registrations
from public.people
where supplierid = 609
and dateinscr < date_trunc('day', now())
group by day
order by day
) subQ

This gives me correct output like this:

day | registrations | rtotal
---------------------+---------------+--------
2008-04-14 00:00:00 | 1 | 1
2008-04-17 00:00:00 | 11 | 12
2008-04-18 00:00:00 | 24 | 36
2008-04-19 00:00:00 | 14 | 50
2008-04-20 00:00:00 | 13 | 63
2008-04-21 00:00:00 | 6 | 69
2008-04-22 00:00:00 | 2 | 71
2008-04-23 00:00:00 | 12 | 83
2008-04-24 00:00:00 | 5 | 88
2008-04-25 00:00:00 | 13 | 101
2008-04-26 00:00:00 | 11 | 112

Then I want to subselect on this and do:

select *
from
(
select day, registrations, runningsum(cast('myregistrations' as text),
cast(registrations as int4)) as rtotal
from
(
select cast(to_char(dateinscr, 'YYYY-MM-DD') as timestamp) as day,
count(*) as registrations
from public.people
where supplierid = 609
and dateinscr < date_trunc('day', now())
group by day
order by day
) subQ
) subq2
Where day > '2008-04-24'

And I would expect to get
day | registrations | rtotal
---------------------+---------------+--------
2008-04-25 00:00:00 | 13 | 101
2008-04-26 00:00:00 | 11 | 112

Instead, the optimizer sees what I'm trying to do, moves the where clause
inside the subquery and my output becomes

day | registrations | rtotal
---------------------+---------------+--------
2008-04-25 00:00:00 | 13 | 13
2008-04-26 00:00:00 | 11 | 24

What can I do to tell the optimizer to keep its hands off my query or at
least get it to not optimize?


Thanks,
Peter


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [HACKERS] Hint Bits and Write I/O

Kevin Grittner wrote:
>>>> On Wed, May 28, 2008 at 6:26 PM, in message
> <483DEA2D.3010704@phlo.org>,
> "Florian G. Pflug" <fgp@phlo.org> wrote:
>
>> I think we should put some randomness into the decision,
>> to spread the IO caused by hit-bit updates after a batch load.
>
> Currently we have a policy of doing a VACUUM FREEZE ANALYZE on a table
> after a bulk load, or on the entire database after loading a pg_dump
> of a database. We do this before putting the table or database into
> production. This avoids surprising clusters of writes at
> unpredictable times. Please don't defeat that. (I'm not sure whether
> your current suggestion would.)

No, VACUUM (and therefore VACUUM FREEZE) dirty all buffers they set hit
bits on anyway, since they also update the xmin values. But a more
IO-friendly approach to setting hit bits might make that VACUUM FREEZE
step unnecessary ;-)

regards, Florian Pflug

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

[BUGS] BUG #4213: Problem at installing this version

The following bug has been logged online:

Bug reference: 4213
Logged by: ROUSSEAU Jacques
Email address: jacques.rousseau.selco@eolane.com
PostgreSQL version: 8.1.11
Operating system: Serveur 2003 R2
Description: Problem at installing this version
Details:

After the screen of installing "Activation des modules de contribution", we
have a error message.
"Echec de la recherche de compte en interne. Le mappage entre les noms de
compte et les ID de sécurité n'a pas été effectué."

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

[BUGS] BUG #4212: Documentation re upgrading

The following bug has been logged online:

Bug reference: 4212
Logged by: Frank Millman
Email address: frank@chagford.com
PostgreSQL version: 8.3.1
Operating system: Fedora 7
Description: Documentation re upgrading
Details:

Section 15.4 of the Manual - Upgrading

[...]

1. If making a backup, make sure that your database is being updated.

This should say *not* being updated.

The docs for 8.2.0 show the following -

1. Make sure that your database is not updated during or after the backup.

The error must have crept in when this wording was amended.

Frank Millman

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs