Re: [GENERAL] Single Table Report With Calculated Column

2014-08-29 Thread Rich Shepard
queries into a with/cte (2 items) and do a normal inner join... Or Select ... From (first query) fq join (second query) sq on (...) Both of which need more study on my part. I read about CTEs and did not then see how to apply them to my needs. Many thanks, Rich -- Sent via pgsql-general

Re: [GENERAL] Single Table Report With Calculated Column

2014-08-29 Thread Rich Shepard
work. Rich -- 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] Employee modeling question

2014-09-05 Thread Rich Shepard
u might need many-to-many tables to keep track of the complex relationships. This is all covered in the chapters on DDL (Data Definition Language) and is separate from the chapters on DML (Data Manipulation Language). Good luck, Rich -- Sent via pgsql-general mailing list (pgsql-general

Re: [GENERAL] Database Design: Maintain Audit Trail of Changes

2013-01-03 Thread Rich Shepard
it, however, if it grows out of affordable bounds). Yes, the history table will be read-only to all users; writing done by triggers only. Much appreciated, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.post

Re: [GENERAL] Getting Mysql data into Postgres: least painful methods?

2013-01-11 Thread Rich Shepard
re were no errors. Took a bit of time but worked just fine. Then I sent the USGS database maintainer a dump of the postgres database because he wanted to migrate from mysql to postgres there. I think of it as a public service. :-) Rich -- Sent via pgsql-general mailing list (pgsql-general@post

[GENERAL] Combine Date and Time Columns to Timestamp

2013-01-18 Thread Rich Shepard
orked with timestamp values before. What is the most parsimonious way to combine the two columns into one? TIA, Rich -- 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] Combine Date and Time Columns to Timestamp

2013-01-18 Thread Rich Shepard
On Fri, 18 Jan 2013, Adrian Klaver wrote: How are they stored, as date and time type, strings, other? Adrian, ISO date and time. A sample of the data would help also. Example: 2012-10-29 | 10:19 | 2012-10-30 | 09:40 Rich -- Sent via pgsql-general mailing list (pgsql-general

Re: [GENERAL] Combine Date and Time Columns to Timestamp

2013-01-19 Thread Rich Shepard
On Fri, 18 Jan 2013, Adrian Klaver wrote: test=> SELECT ('2012-10-29 '||'10:19')::timestamp; timestamp - 2012-10-29 10:19:00 Thanks, Adrian. I suspected it was simple but I could not find a reference to the syntax. Much appreciated, Ri

[GENERAL] Yet Another Timestamp Question: Time Defaults

2013-01-21 Thread Rich Shepard
What is the behavior if a column data type is timestamptz but there is only the date portion available? There must be a default time; can that be defined? Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http

Re: [GENERAL] Yet Another Timestamp Question: Time Defaults

2013-01-21 Thread Rich Shepard
On Mon, 21 Jan 2013, Adrian Klaver wrote: Easy enough to test: Thanks again, Adrian. Rich -- 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] Yet Another Timestamp Question: Time Defaults

2013-01-21 Thread Rich Shepard
default supplied by Postgres, "SET timezone" ought to do it ... Thanks, Tom. Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] Restore 1 Table from pg_dumpall?

2013-01-22 Thread Rich Shepard
around in it. Is there a way I can extract a single table's schema and data from the full backup? If so, I can then drop the fubar'd table and do it correctly this time. Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscrip

Re: [GENERAL] Restore 1 Table from pg_dumpall? [RESOLVED]

2013-01-22 Thread Rich Shepard
On Tue, 22 Jan 2013, Rich Shepard wrote: Is there a way I can extract a single table's schema and data from the full backup? If so, I can then drop the fubar'd table and do it correctly this time. My solution: view the file in the pager I use (less), then copy relevant lines

Re: [GENERAL] Restore 1 Table from pg_dumpall? [RESOLVED]

2013-01-22 Thread Rich Shepard
On Tue, 22 Jan 2013, Joshua D. Drake wrote: Rich, the main problem is using pg_dumpall. Unfortunately pg_dumpall has not kept up with all the other advances Postgres has had in the last decade. To set up dump based backups properly I suggest reviewing: http://www.commandprompt.com/blogs

Re: [GENERAL] Restore 1 Table from pg_dumpall?

2013-01-27 Thread Rich Shepard
On Sun, 27 Jan 2013, Jasen Betts wrote: yeah, emacs is slow on large files. Jasen, I've noticed this over the years. for a one-off I'd use less(1), to extract the desired table data. If I had to repeat it i'd use sed or awk I used 'joe'. It handled the job wi

Re: [GENERAL] seeking SQL book recommendation

2013-01-27 Thread Rich Shepard
s and extensive discussion on temporal queries. And, Joe Celko's 'SQL for Smarties' at whichever edition is current to learn some of the non-syntactical aspects that effect database development and use. Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make chan

[GENERAL] COPY table to file missing quotation marks

2013-01-31 Thread Rich Shepard
and here're part of the header and following row of the output: siteid|sampdate|analdate|ph|cond|turb|tss|doc|dic|p|se|ca|mg|na|k|nh4|so4|no3 1993SBOIA049|2004-06-28|2004-06-28|7.67|117|4.21|6.1|1.13|11.96|40|0.2|503.5|206.2 I'm sure it's something simple in the syntax I k

Re: [GENERAL] COPY table to file missing quotation marks

2013-01-31 Thread Rich Shepard
or, better yet, write a one-line awk program that quotes the appropriate tokens! That's what I'll do. Thanks, Rich -- 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] COPY table to file missing quotation marks

2013-01-31 Thread Rich Shepard
this way since the early 1980s. Rich -- 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] COPY table to file missing quotation marks

2013-01-31 Thread Rich Shepard
format. Use FORCE_QUOTE * to quote all columns. Adrian, That's correct. Most of the columns are numeric so each text column needs to be specified. Thanks, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

[GENERAL] New 9.6.2 installation lacks /usr/lib/postgresql/

2017-02-25 Thread Rich Shepard
Builds.org build script which I've used for many years so I don't know where to start looking for the reason there's no postgres lib/ directory. Diagnostic help appreciated. Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes t

Re: [GENERAL] New 9.6.2 installation lacks /usr/lib/postgresql/

2017-02-25 Thread Rich Shepard
nfiguration process or create a symlink . Well, sure. As long as I provide grass with the proper path in the config file it's happy. Thanks, Rich -- 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] New 9.6.2 installation lacks /usr/lib/postgresql/ [RESOLVED]

2017-02-26 Thread Rich Shepard
On Sat, 25 Feb 2017, Rich Shepard wrote: Just installed postgresql-9.6.2 on Slackware-14.2/x86_64 and initialized the database. However, there's no /usr/lib/postgresql/ directory with its subdirectories. Duh! It's in /usr/lib64/postgresql. Sigh, Rich -- Sent via pgsql-gener

[GENERAL] Upgradede -9.6.1 to -9.6.2; postmaster will not start

2017-03-10 Thread Rich Shepard
5. Tried commenting out that line to match backup, but that also did not allow postgres to start. 6. All files are owned by postgres.users. Please teach me how to fix this. TIA, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

[GENERAL] INSERT and ON CONFLICT

2017-03-10 Thread Rich Shepard
NG is exactly what I want to include in the command. Have I correctly interpreted what the DO NOTHING option does when a row to be inserted already is present in the table? Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] Upgradede -9.6.1 to -9.6.2; postmaster will not start

2017-03-10 Thread Rich Shepard
new one is available. This is a new error for me. In any case, you should be able to fix it by making a copy of your pre-upgrade pg_hba.conf and shoving that back into the data directory afterwards; I'll restore a backup copy from last month. Thanks, Rich -- Sent via pgsql-

Re: [GENERAL] INSERT and ON CONFLICT

2017-03-10 Thread Rich Shepard
On Fri, 10 Mar 2017, Brian Dunavant wrote: I believe the following test should answer your question. Thank you, Brian. It does answer my question. Regards, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http

Re: [GENERAL] Upgradede -9.6.1 to -9.6.2; postmaster will not start

2017-03-10 Thread Rich Shepard
On Fri, 10 Mar 2017, Rich Shepard wrote: Actually, it has the modifications I've made over the years. That's why I could not see what changed. Well, postgres was running yesterday and allowed me to access my bookkeeping software so obviously something did change without my manual

Re: [GENERAL] Upgradede -9.6.1 to -9.6.2; postmaster will not start [FIXED]

2017-03-10 Thread Rich Shepard
its should have been changed to something else. It certainly wasn't working before if it was like this, either. Tom, I've no idea how the file was changed, but something certainly happened to it. Restoring pg_hba.conf from 2016-09-17 (when pg-9.5.1 was installed) certainly fixed

Re: [GENERAL] Upgradede -9.6.1 to -9.6.2; postmaster will not start

2017-03-10 Thread Rich Shepard
file anywhere in the source or build trees so I've no idea from where this unworkable version came. Thanks, Rich -- 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] Postgres backup solution

2017-03-14 Thread Rich Shepard
sync and records only changes since the last run. I use it to back up my server/workstation daily. I've restored files accidently deleted with no problems using either cp or rsync. That's my $0.25 worth (inflation, you know). Regards, Rich -- Sent via pgsql-general mailing list (pg

[GENERAL] INSERT INTO: string with apostrophe

2017-06-29 Thread Rich Shepard
The syntax for inserting data into a table uses single quotes to identify strings. When I have a string such as O'Brien do I double the single quotes within the string (i.e., 'O''Brien') or is there another way to include such strings? Rich -- Sent via pgsql-ge

Re: [GENERAL] INSERT INTO: string with apostrophe

2017-06-29 Thread Rich Shepard
Thanks for confirming. Regards, Rich -- 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] DATA Integrity & Recovery

2017-07-12 Thread Rich Shepard
or why they mattered, but each week I run pg_dumpall and save the .sql file in a database_backup/ directory. This does not answer your specific questions but does offer a strategy for future operations. HTH, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] Oracle Analytical Functions

2008-01-31 Thread Adam Rich
> > I'm trying to replicate the use of Oracle's 'lag' and 'over > > partition by' analytical functions in my query. I have a table > > (all_client_times) such as: > > and I would like to create a new view that takes the first table and > > calculates the time difference in minutes between each row

Re: [GENERAL] Oracle Analytical Functions

2008-01-31 Thread Adam Rich
Hi Willem, > for some reason the order by's aren't working. Could you provide more details? Do you get a specific error message? > only returning 658 rows instead of the 750K. You should not expect the same row count in both source table and result set. Even in your example -- you provided 8

Re: [GENERAL] Oracle Analytical Functions

2008-01-31 Thread Adam Rich
;seq2') as s, * from (select client_id, arbnum from arb_test order by client_id, arbnum OFFSET 0)as z OFFSET 0) as b on a.s=(b.s-1) where a.client_id=b.client_id; > -Original Message- > From: Willem Buitendyk [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 31, 2008 2:48 PM &

Re: [GENERAL] Dump schema without the functions

2008-01-31 Thread Adam Rich
> how can I dump a schema with all tables, but without the functions? Is > there a way to do it, or do I have to manually drop the functions > later when having used the pg_restore? Stef, You can edit the data between dump and restore, to comment out the function references. Or, you can use the "-

[GENERAL] Subquery Factoring ?

2008-02-07 Thread Adam Rich
Are there any plans to support materialized subquery / factoring (sql-99 WITH) in Postgresql? I am spoiled with this feature in oracle, and find myself wishing I had it in postgresql more and more. It *seems* to an outsider like a relatively easy addition. I searched the archives but only fou

Re: [GENERAL] Subquery Factoring ?

2008-02-07 Thread Adam Rich
Gregory, > Are you using it just to avoid retyping a complex subquery? Or do you > expect > that the feature will reduce the execution time by avoiding re- > executing the > subquery for each call site in the query? The only situation where I rely on this currently is when my main/outer query re

Re: [GENERAL] help optimizing query

2008-02-09 Thread Adam Rich
> It seems to do the job, but how good is it in the long run? Any way I > could tweak it? I think this form will work the best: SELECT u.login, MAX(s.stop_time) AS last_use_time FROM users u, stats s WHERE u.id=s.user_id AND u.status='3' AND u.next_plan_id IS NULL GROUP BY u.login HAVING MAX(s.

Re: [GENERAL] Storing images as BYTEA or large objects

2008-02-12 Thread Adam Rich
> > I have two options for storing this data: As BYTEA or as large objects. Is it true that if you update a row containing a large BYTEA value, (even if you're not updating the BYTEA field itself, just another field), it requires the entire BYTEA value to be copied to a new row (because of MVCC)

Re: [GENERAL] the feasibility of sending email from stored procedure in Postgres

2008-02-15 Thread Adam Rich
> I would instead queue messages (or suitable information about them) in > a table, and have a process outside PostgreSQL periodically poll for them Why poll when you can wait? http://www.postgresql.org/docs/8.2/interactive/sql-notify.html ---(end of broadcast)-

Re: [GENERAL] no-arg cluster and locks ...

2008-02-24 Thread Adam Rich
> Can you provide more details? pg_locks, pg_stat_activity, the deadlock > message? > > (Hmm, it would be helpful if the deadlock checker were to save the > pg_locks contents and perhaps pg_stat_activity in a file, whenever a > deadlock is detected.) Great idea! As somebody who's spent hours tr

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Adam Rich
> I wanted to use the following statement to "translate" the relkind > column to a > more descriptive value: > > select c.relname > case > when c.relkind in ('t','r') then 'table' > when c.relkind = 'i' then 'index' > when c.relkind = 'S' then 'sequence' >

Re: [GENERAL] Confused about CASE

2008-02-29 Thread Adam Rich
> "The data types of all the result expressions must be convertible to a > single output type." The type of the field pg_class.relkind appears to be "char" which is described in the notes as: The type "char" (note the quotes) is different from char(1) in that it only uses one byte of storage. It

Re: [GENERAL] Efficiently storing a directed graph

2008-03-01 Thread Adam Rich
> I'm not married to using SQL: are there other efficient solutions to > store directed graphs? Could I hack something up in Perl or Ruby and > then serialize my in-memory graph to a file (for efficient > saving/reloading)? As far as a perl solution, I would suggest posting your problem on perlmon

Re: [GENERAL] How to convert postgres timestamp to date: yyyy-mm-dd

2008-03-11 Thread Adam Rich
> I need to convert postgres timestamp to date format -mm-dd in a > sql statement. > pt.created_date below is timestamp format > > i.e ... WHERE pt.created_date >= '2008-01-21' > > Any help would be greatly appreciated. Try this: WHERE pt.created_date >= '2008-01-21'::date -- Sent v

Re: [GENERAL] Column Statistics - How to dertermine for whole database

2008-03-12 Thread Adam Rich
> Is there a query to pg_catalog tables to find out which table/column > has > the stat level not at default in 1 sweep? Try this: select c.relname, a.attname, attstattarget from pg_catalog.pg_attribute a, pg_catalog.pg_class c, pg_catalog.pg_namespace n where a.attrelid = c.oid and c.relnamespac

[GENERAL] 8.3.0 upgrade

2008-03-17 Thread Adam Rich
I just finished upgrading my production DB to 8.3.0. Everything went smoothly, but I thought of a few questions. After the upgrade, while restoring my backup to the new version, I got this error message: ERROR: role "postgres" already exists I assume this is nothing to be concerned about. B

Re: [GENERAL] 8.3.0 upgrade

2008-03-17 Thread Adam Rich
Thanks to Pavan for the answer regarding HOT. Does anybody have an answer regarding the postgres role or compat lib ? > > * From: "Adam Rich" > * To: > * Subject: 8.3.0 upgrade > * Date: Mon, 17 Mar 2008 02:13:55 -0500 > > > I just fini

Re: [GENERAL] MySQL to Postgres question

2008-03-21 Thread Adam Rich
> > I am not sure about 8.3 but certainly earlier releases of PostgreSQL > > would have specific dependency issues when a sequence was applied to > a > > a column after the fact, versus using the serial or bigserial > > psuedo-types. I'd like to point out that using pg_dump does in fact apply sequ

Re: [GENERAL] 8.3.0 upgrade

2008-03-21 Thread Adam Rich
> Pick your OS/Arch from this list, and click to it: > > http://yum.pgsqlrpms.org/rpmchart.php > > Then click to "C" at the top, and download the compat package. Devrim, I clicked on my OS (RHEL/CentOS 4 - x86) Then on "C" as you said, But the RPM list still only contains the compat-postgresql-l

Re: [GENERAL] 8.3.0 upgrade

2008-03-21 Thread Adam Rich
> No, you need compat-3, not compat-4. For example: > > [EMAIL PROTECTED] ~]# yum install php-pgsql > --> Processing Dependency: libpq.so.3 for package: php-pgsql I have applications that depend on libpq.so.4 Where do I get that, if not compat-postgresql-libs-4-2 ?? -- Sent via pgsql-general

Re: [GENERAL] MySQL to Postgres question

2008-03-22 Thread Adam Rich
> The short answer is that Adam's statement is wrong, or at least > misleading. Sorry Tom, I wasn't trying to do either. Joshua Drake (who I understand to be a reliable source of postgresql information) said that applying a sequence to a column after creation created issues, versus using the seri

Re: [GENERAL] How to sort strings containing a dot?

2008-03-25 Thread Adam Rich
> By the way, I have just inserted a duplicate. Then I have run the > select statement with distinct and I got an error. > > How one can solve this? > Does this work? select distinct name from ( select name from t order by replace(name, '.', 'a')) as t2 -- Sent via pgsql-general mailing li

Re: [GENERAL] Survey: renaming/removing script binaries (createdb, createuser...)

2008-03-26 Thread Adam Rich
> > Please let us know your meaning, > > thanks Zdenek Kotala > 1. c 2. a 3. other = "pginitdb", to be consistent with pgcreatedb,etc 4. a -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mai

Re: [GENERAL] casting from integer to boolean

2008-03-26 Thread Adam Rich
> Thanks Richard. Is there a way to do it without changing the INSERT > command? As I mentioned, there are many more columns of different > types, so finding and replacing the VALUES would be very difficult. Can you import the data into a holding table (with columns defined as integer) first, an

Re: [GENERAL] Survey: renaming/removing script binaries (createdb, createuser...)

2008-03-27 Thread Adam Rich
> > Oh, then there should have been some options in the survey along the > > lines of "things are fine how they are." > > Oh, a bit of answer-forcing wasn't beneath him. Ummm... Isn't that what Option A is about ? 1) What type of names do you prefer? --- a) old no

Re: [GENERAL] Need help on how to backup a table

2008-03-28 Thread Adam Rich
> Hi all, > I am trying to backup a large table with about 6 million rows. I want > to > export the data from the table and be able to import it into another > table > on a different database server (from pgsql 8.1 to 8.2). I need to > export the > data through SQL query 'cause I want to do a gr

Re: [GENERAL] SQL question

2008-03-28 Thread Adam Rich
> I have a table that has 3 date columns : > > create table xyz ( > xyz_id integer, > date1 timestamp, > date2 timestamp, > date3 timestamp > ) > > > I want to select in a query the xyz_id and the max date column for > each row > something like : > create table temp2 as select xyz_id (max

Re: [GENERAL] Update Join ?

2008-04-01 Thread Adam Rich
>> Does Postgres allow updates based on the context of a sub-query, something like the sample below ? Yes, Update real_tab set real_tab.data_desc = temp_tab.data_desc >From temp_tab Where real_tab.keyID = temp_tab.keyID (don't repeat your updated table in the "from" list unless you Mean to self

Re: [GENERAL] Serial Data Type

2008-04-02 Thread Adam Rich
> I have just created a table using SELECT INTO however the PK was > supposed to be a serial. It is now an integer. To make it a serial I > just create the seq and set the default to be the nextval() of that > sequence right? is there anything else I need to do? You'll want to do this: ALTER SE

Re: [GENERAL] Secure "where in(a,b,c)" clause.

2008-04-03 Thread Adam Rich
> I hope this isn't a FAQ, but does anyone have any > suggestions as to > how to make a query that selects using: > "where in()" > secure from an sql injection point of view? > > As the length of the comma delimited list is highly > variable I don't > think I can use a prepared query to increase

Re: [GENERAL] SQL injection, php and queueing multiple statement

2008-04-11 Thread Adam Rich
> Is there a switch (php side or pg side) to avoid things like: > > pg_query("select id from table1 where a=$i"); > > into becoming > > pg_query("select id from table1 where a=1 and 1=1; do something > nasty; -- "); Ideally, you'd use this: pg_query_params('select id from table1 where a=$1', a

Re: [GENERAL] Unable to add a new column to a table named "in" (look like a bug ...)

2008-04-17 Thread Adam Rich
> Could you just have a look to the output below? I try to add a column > to a > table named "in" (I know "in" is a reserved keyword but the table > exists and > I cannot change it). Postgresql complains that the column already > exist but > it didn't. Am I doing something wrong ? Try: ALTER T

Re: [GENERAL] Unable to add a new column to a table named "in" (look like a bug ...)

2008-04-17 Thread Adam Rich
> > It worked Thanks!! But there is definitly something wrong with the > error > message I got (right?): > > reference=# alter table "IN" add column INDESCS VARCHAR[]; > ERROR: column "indescs" of relation "IN" already exists > I don't know, what do you see when you \d "IN" ? When you use d

Re: [GENERAL] Conditional on Select List

2008-05-13 Thread Adam Rich
> > Is it possible to do this? > > SELECT IF(COUNT(colname) > 0, TRUE, FALSE) AS colname FROM table; > > What I want is to return a boolean, but when I tried SELECT > COUNT(colname)::BOOLEAN FROM table; it says it cannot cast bigint to > boolean. > How about this? Logic al expresses are alrea

Re: [GENERAL] Finding records that are not there

2008-05-22 Thread Adam Rich
> I have two tables that have identical index fields, maplot and > unitno, (both indexes span two columns) and I want to find all the > records in the commcost table that don't have a corresponding record > in the bldg file. > > The SQL I've tried is: > > select commcost.maplot, commcost.unitno

Re: [GENERAL] Results of stored procedures in WHERE clause

2008-05-22 Thread Adam Rich
> > I need to be able to do queries that restrict my result set to items > belonging to a specified site and ignore all nodes that belong to > different sites. To determine the ID of the site an item belongs to I > wrote a stored procedure: > > This returns the ID of the root node for non-root

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

2008-05-30 Thread Adam Rich
> 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

Re: [GENERAL] Multiple result sets

2008-06-01 Thread Adam Rich
> I need that 5 queries, fired from the same ajax request to a web > python application, see the same database snapshot. The driver is > psycopg2. > > Since postgresql 8.2 functions can't return multiple result sets what > would be the best aproach? > You want to set your transaction isolation

Re: [GENERAL] Multiple result sets

2008-06-01 Thread Adam Rich
> >> I need that 5 queries, fired from the same ajax request to a web > >> python application, see the same database snapshot. The driver is > >> psycopg2. > >> > >> Since postgresql 8.2 functions can't return multiple result sets > >> what would be the best aproach? > >> > > You want to set your

Re: [GENERAL] Multiple result sets

2008-06-01 Thread Adam Rich
> > I am not familiar with the python library, but that looks correct > > to me. You can always test it by adding a sleep between your two > > queries and modifying the database from a console connection > > during the sleep. > > > Note that I'm assuming your 5 queries are all read-only selects.

Re: [GENERAL] hopefully a brain teaser, can't quite figure out query

2008-06-07 Thread Adam Rich
> -Original Message- > The small table is a listing of county fips codes, their name, and the > geometry for the county. Each fips is only listed once. The big table > is multiple emissions for each county, the parameter for the emission, > and the source code for the emission (scc). Each

Re: [GENERAL] IN vs EXISTS

2008-06-07 Thread Adam Rich
> -Original Message- > > Hi all, > > I have been using IN clause almost exclusively until recently I tried > to use EXISTS and gained significant performance increase without > changing/creating any indexes: > > SELECT ... FROM a WHERE a.ref IN (SELECT b.id WHERE ...) > > vs > > SELECT

[GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-17 Thread Rich Shepard
l start. It reported that the server was already running, but that it started anyway. 7.) A search of the process list could not find the postmaster process, or any other indication of pgsql running. Trying to run pgsql as a user also failed. Tried, as user postgres, to run 'pg_sql start

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-17 Thread Rich Shepard
. Try "initdb --help" for more information. But, using the -E option with en_US tells me that it's not a valid locale. Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.|Innovation <htt

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-17 Thread Rich Shepard
n (as user postgres) 'initdb -D /var/lib/pgsql/data'. Nothing! I've really FUBARed this and don't understand how, or what to do to recover. Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
8.3 server. Every file from /var/lib/pgsql/ before I started this is on the weekly backup tape from last Friday night. If need be I can restore from that and start over. Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Ser

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
or pg_ctl -D /var/lib/pgsql/data -l logfile start Notice the warning detail about us_EN encoding. Is there a protocol for what to include in a report to pgsql-bugs? I will now try a new dumpall using the 8.3.3 version, once I find how to specify a different $PGDATA on the command line. Rich

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
same time it is easy to get cross reference problems. Adrian, No messages, other than that us_EN was not an encoding found in the locale. Re-running initdb specifying UTF8 worked. I've no idea if this affects the existing databases. Thanks, Rich -- Richard B. Shepard,

[GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
/usr4/pgsql_old/data/ and write it to a file (with the -f option) in /usr4/postgres-backups. There are no postmaster or postgres processes running. Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
d upgrading the PostgreSQL installation, having folks telling me all I did incorrectly is not as helpful to me as guidance on getting the cluster correctly transferred from the 8.1.4 version to the 8.3.3 version. My readings and research obviously did not sufficiently educate me on the proper process.

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
m the backup tape, as well as /usr/share/postgresql/, /usr/include/postgresql/, and /usr/bin/postgres? Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.|Innovation <http://www.appl-ecosys.com> Voi

Re: [GENERAL] Need Help Recovering from Botched Upgrade Attempt

2008-06-18 Thread Rich Shepard
f, unless there's an egregious error here. In that case, please let me know!) Results when I have them. Thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.|Innovation <http://www.appl-ecosys.com&

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
hown. Sure enough, the pid file is not present, nor is process 18162 there. Much closer, Josh, but not quite there yet. Many thanks, Rich -- Richard B. Shepard, Ph.D. | IntegrityCredibility Applied Ecosystem Services, Inc.|Innovation <http://w

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
ll doing something incorrectly. In /usr4/postgres-backups, I did: [EMAIL PROTECTED] /usr4/postgres-backups]$ pg_restore -U postgres < pg814data.sql pg_restore: [archiver] input file does not appear to be a valid archive But it was created using the 8.3.3 pg_dumpall in /usr/bin/. Much cl

Re: [GENERAL] Correct pg_dumpall Syntax

2008-06-18 Thread Rich Shepard
t's in /var/log/apache/error.log, so that's where I need to start fixing what broke. Thanks to everyone here. I think the upgrade has finally been successful. I learned a lot, and will try to make the next upgrade both much sooner and more smooth. Rich -- Richard B. Shepard, Ph.D.

Re: [GENERAL] what are rules for?

2008-06-23 Thread Adam Rich
> > Can you describe, or point me to somewhere which describes, all the > things you can do with a rule that you can't do with a trigger? The > only examples of rules in the manual are (1) logging, which I've just > been told is much better done with a trigger, and (2) making update, > insert, an

Re: [GENERAL] compiling, performance of PostGreSQL 8.3 on 64-bit processors

2008-06-26 Thread Adam Rich
> 1. I have heard of problems arising from compiling PostGreSQL (8.3) on > 64-bit > processors. What sort of problems am I likely to encounter and how > should I fix > them? We are will run Linux Redhat 5 on a Dell PE2950 III Quad Core > Xeon E54 > 2.33 GHz, and a Dell PE2950 III Quad Core Xeon

Re: [GENERAL] Advice Wanted on Selecting Multi-row Data Requests in 10-Row Blocks

2008-06-27 Thread Adam Rich
> > What I want to do is present the results of a query in a web page, but > only 10 rows at a time. My PostgreSQL table has millions of records and > if I don't add a LIMIT 10 to the SQL selection, the request can take > too > long. The worst case scenario is when the user requests all records >

Re: [GENERAL] query planner weirdness?

2008-06-27 Thread Adam Rich
> > "Bob Duffey" <[EMAIL PROTECTED]> writes: > > I'm seeing some query plans that I'm not expecting. The table in > question > > is reasonably big (130,000,000 rows). The table has a primary key, > indexed > > by one field ("ID", of type bigint). Thus, I would expect the > following > > query

[GENERAL] Date math

2009-06-27 Thread Adam Rich
Hello, I have a table with a DATE field "birth_date". The data obviously contains various dates in the past, such as 07/04/1970. In my query, I need to retrieve the person's "next" birthday. In other words, for the example date 07/04/1970, the query should return 07/04/2009 for the current

Re: Fwd: [GENERAL] Date math

2009-06-27 Thread Adam Rich
Guy Flaherty wrote: On Sun, Jun 28, 2009 at 1:52 PM, Adam Rich <mailto:ada...@sbcglobal.net>> wrote: Hello, I have a table with a DATE field "birth_date". The data obviously contains various dates in the past, such as 07/04/1970. In my query, I need to re

Re: [GENERAL] Overhead of union versus union all

2009-07-09 Thread Adam Rich
Tim Keitt wrote: I am combining query results that I know are disjoint. I'm wondering how much overhead there is in calling union versus union all. (Just curious really; I can't see a reason not to use union all.) (cc me please; not subscribed...) THK I think you can test this one yourself p

Re: [GENERAL] Design Database, 3 degrees of Users.

2009-07-31 Thread Rich Shepard
S that depend on the priviledges associated with each user when logged into the system. It appears to me that you ought to take a step back and learn a bit more about application development which uses a DBMS as a data storage back end. Rich -- Richard B. Shepard, Ph.D. | Integrity

Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Adam Rich
Andre, See this PHP page: http://www.php.net/manual/en/function.pg-last-notice.php Andre Lopes wrote: Hi, I'm developing a function with some checks, for example... to check if the e-mail is valid or not. If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not valid'. I n

Re: [GENERAL] how to return field based on field= NULL or not

2009-08-23 Thread Adam Rich
Juan Backson wrote: Hi, In my table, I have fieldA and fieldB. At any point in time, only one of these fields can have data in it. The other is NULL. Instead of "select fieldA, fieldB from table", I want it to return either fieldA or fieldB depends on whether it is NULL or not. The re

Re: R: [GENERAL] Field's position in Table

2009-08-24 Thread Adam Rich
From: vinny Subject: Re: R: [GENERAL] Field's position in Table To: "Sam Mason" Cc: pgsql-general@postgresql.org Date: Monday, August 24, 2009, 2:38 PM On Thu, 2009-08-20 at 12:16 +0100, Sam Mason wrote: > On Thu, Aug 20, 2009 at 11:24:49AM +0200, vinny wrote: > > I can't really think of any r

<    1   2   3   4   5   6   7   8   >