Re: [SQL] Does PG have a database

2006-05-22 Thread Manlio Perillo
Mark Fenbers ha scritto:
> I have working PostgreSQL databases on 3 of my ~30 Linux boxes.  I want
> my software to be able to determine which of my 30 boxes have functional
> databases on them.  Since Pg is part of the baseline distro, merely
> checking for the existence of an executable doesn't solve my problem.
> 
> I tried looping through my list of hosts and running the command:
>psql -h $host --list
> but this fails on a box with a database with the same error code as on a
> box that doesn't have a database, if my PGUSER isn't set and my login ID
> is not the username of the database.  The PGUSER setting might differ
> for each host, so specifying this in the software is not practical.
> 
> Bottom line:  What trick can I use to determine whether a box has a
> living, breathing Pg database if I don't know the DB owner?
> Mark
> 


Just write a custom client that connects to the given host, on some
standard ports.

If the connection is accepted, there is a possibility that on the other
side there is a PostgreSQL server.

To make sure send a StartupMessage
http://www.postgresql.org/docs/8.1/static/protocol-message-formats.html


You can reuse some code of a library I have written: pglib.
http://developer.berlios.de/projects/pglib/

It is released under the MIT license, and it is written in Python and
Twisted (a framework for writing asynchronous applications).

By the way: pglib aims to be a complete replacement for libpq.




Regards  Manlio Perillo

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


[SQL] primary keys as TEXT

2006-07-28 Thread Manlio Perillo
Hi.

There can be performancs problems in having primary keys of type TEXT?
What about having a primary key of 3 columns (all of type TEXT)?


Regards  Manlio Perillo

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


Re: [SQL] primary keys as TEXT

2006-07-28 Thread Manlio Perillo
Michael Glaesemann ha scritto:
> 
> On Jul 28, 2006, at 17:37 , Manlio Perillo wrote:
> 
>> There can be performancs problems in having primary keys of type TEXT?
>> What about having a primary key of 3 columns (all of type TEXT)?
> 
> What defines a problem in terms of performance is heavily dependent on
> your particular needs and requirements. What are your requirements? What
> profiling have you done to see where your performance bottlenecks may be?
> 

I still don't have done profiling.

Simply in the first version of my schema I used serial keys but the
result is ugly and it force me to do a lot of joins.




Thanks and regards  Manlio Perillo

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


Re: [SQL] primary keys as TEXT

2006-07-31 Thread Manlio Perillo
Aaron Bono ha scritto:
> On 7/28/06, *Manlio Perillo* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> Michael Glaesemann ha scritto:
> >
>     > On Jul 28, 2006, at 17:37 , Manlio Perillo wrote:
> >
> >> There can be performancs problems in having primary keys of type
> TEXT?
> >> What about having a primary key of 3 columns (all of type TEXT)?
> >
> > What defines a problem in terms of performance is heavily dependent on
> > your particular needs and requirements. What are your
> requirements? What
> > profiling have you done to see where your performance bottlenecks
> may be?
> >
> 
> I still don't have done profiling.
> 
> Simply in the first version of my schema I used serial keys but the
> result is ugly and it force me to do a lot of joins.
> 
> 
>  
> Ugly?  Not sure what you mean by that.
> 

Because serial ids are only surrogate keys.
My tables have well definited primary keys, the only problem is that
they are of type TEXT (and spawn up to 3 columns).

My concern is: how bad can be performance?

> I do understand the problem with so many joins.  I use views so that the
> joins are only delt with once (in the database) and then all my
> applications run off the views.  That way, the applications use very
> simple queries.  The views also allow me to change the table structure
> (column names, more table normalization, etc.) without having to make
> changes to the application.
> 

View are a good idea, thanks.


Regards  Manlio Perillo

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