Re: [SQL] DELETE FROM takes forever

2011-02-10 Thread Chris Browne
slus...@gmail.com (Josh) writes: > I'm trying to do a DELETE FROM on my large table (about 800 million > rows) based on the contents of another, moderately large table (about > 110 million rows). The command I'm using is: > > DELETE FROM records WHERE id NOT IN (SELECT id FROM unique_records); > >

Re: [SQL] Get postgresql server ip address

2011-02-08 Thread Chris Browne
gerame...@gmail.com (Gera Mel Handumon) writes: > Is it possible to get postgresql server ip address using sql command? You can get the IP address tied to a specific connection... See the function inet_server_port(). Note, however, that the server may have a multiplicity of IP addresses, so th

Re: [SQL] oracle to postgres migration question

2010-06-16 Thread Chris Browne
sfr...@snowman.net (Stephen Frost) writes: > People who are trying to parse psql's output directly should realize > they probably are going about it the wrong way. :) There's a set of people I need to tell that to... -- select 'cbbrowne' || '@' || 'cbbrowne.com'; http://cbbrowne.com/info/internet

Re: [SQL] PSQL statement to delete 100 rows meeting certain criteria

2009-12-30 Thread Chris Browne
shulkae writes: > I am newbie to postgres/SQL. > > I want to delete all rows exceeding 400 hours (10 days) and I want to > limit deletion of only 100 records at a time. > > I was trying the following in PostgreSQL: > > DELETE from mytable WHERE (now() - timestamp_field > INTERVAL '400 > hour' ) L

Re: [SQL] Sequences

2009-07-04 Thread Chris Browne
Andre Rothe writes: > Where are stored the sequence information? How I can query the > properties of a sequence like increment, max/min value, cache? > I'm looking for a table like user_sequences in Oracle, where I > can query all of my sequences. cbbrowne=# create sequence foo; CREATE SEQUENCE c

Re: [SQL] ENUM vs DOMAIN vs FKyed loookup table

2009-04-15 Thread Chris Browne
ja...@xnet.co.nz (Jasen Betts) writes: > On 2009-04-12, Dirk Jagdmann wrote: >>> When you need to choose between enum types, domain types or lookup >>> tables with foreign keys, what do you usualy choose? >> >> When I have a column with valid values that I know when writing my >> tables and that w

Re: [SQL] Any utility to convert MySQL to PGSQL?

2009-01-05 Thread Chris Browne
liaogz82 writes: > I am new to Postgresql. I was wondering is there a way to convert > MySQL to Postgres? Is there a utility in the market that does that? There are many possibilities to choose from: http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL -- select 'cbbrow

Re: [SQL] replicating a table in several databases

2008-10-10 Thread Chris Browne
[EMAIL PROTECTED] (Gerardo Herzig) writes: > Hi all. Im facing a situation where i have to replicate a table from > database A in databases B,C,F and so on. > > The first (and only) thing i have in mind is using triggers with dblink > for comunications with the other DB's. > > I dont even like the

Re: [SQL] One Text Table or Multiple Text Tables - Design Tradeoffs?

2008-06-10 Thread Chris Browne
[EMAIL PROTECTED] (Bryan Emrys) writes: > (Trying to start a new thread instead of my accidental intrusion into another > thread) > > Hello Everyone, > > In a text-heavy database, I'm trying to make an initial design decision in > the following context. > > There is a lot of long text that I co

Re: [SQL] Find all instances of a column in the entire database.

2008-05-16 Thread Chris Browne
[EMAIL PROTECTED] ("Gavin 'Beau' Baumanis") writes: > I am hoping that you might be able to give me some assistance with the > following task! > I have a database with nearly 200 tables and I need to find all tables > that contain a column of myColumnName. > > I was hoping there might be a built-in

Re: [SQL] Index to enforce non-overlapping ranges?

2008-05-08 Thread Chris Browne
[EMAIL PROTECTED] (James Robinson) writes: > Academic question here: > > Given a table with a pair of any sort of line-segment-esqe > range delimiter columns, is it possible to build a unique index to > enforce non-overlapping ranges? Such as: > > create table test > ( >

Re: [SQL] trigger for TRUNCATE?

2008-01-10 Thread Chris Browne
[EMAIL PROTECTED] (Tom Lane) writes: > Alvaro Herrera <[EMAIL PROTECTED]> writes: >> Gerardo Herzig escribió: >>> Yes, the TRUNCATE statement is not sql ansi, maybe is a more low level >>> thing than i think. > >> TRUNCATE currently does not fire triggers, but that doesn't mean it's >> impossible

Re: [SQL] trigger for TRUNCATE?

2008-01-08 Thread Chris Browne
[EMAIL PROTECTED] (Gerardo Herzig) writes: > Hi all. Acording to the docs, TRUNCATE will not fire a DELETE trigger > on the table being truncated. > There is a way to capture a TRUNCATE in any way? I think there's some sort of "to do" on that... It ought to be not *too* difficult (I imagine!) to

Re: [SQL] Cheers for DISTINCT ON

2008-01-07 Thread Chris Browne
[EMAIL PROTECTED] (Andrew Sullivan) writes: > On Mon, Jan 07, 2008 at 05:02:27PM +0100, Peter Kovacs wrote: >> I just wanted to give my cheers for DISTINCT ON. It is a great >> feature, I've just found a really good use for it. I am just wondering >> why it didn't make it into the standards. > > Li

Re: [SQL] Cheers for DISTINCT ON

2008-01-07 Thread Chris Browne
[EMAIL PROTECTED] (Bruce Momjian) writes: > Peter Kovacs wrote: >> I just wanted to give my cheers for DISTINCT ON. It is a great >> feature, I've just found a really good use for it. I am just wondering >> why it didn't make it into the standards. >> >> On a slightly unrelated note, I had the opp

Re: [SQL] Incomprehensible dogged sort in Merge Join

2007-08-31 Thread Chris Browne
[EMAIL PROTECTED] (Gregory Stark) writes: > "Aleksandr Vinokurov" <[EMAIL PROTECTED]> writes: > >> Gregory Stark wrote: >>> >>> What version are you running with? >> >> 8.0.1, sorry for missing. > > There have been 12 bug-fix releases since then on the 8.0 branch including > updating timezones to r

Re: [SQL] Reporting functions (OLAP)

2007-08-31 Thread Chris Browne
[EMAIL PROTECTED] (Sean Davis) writes: > I am looking for reporting extensions such as windowing, ranking, > leads/lags, etc. for postgresql. A quick google search turned up > some "working on it" type results, but I was wondering if anything > actually existed up to this point? No, nothing exist

Re: [SQL] Database Synchronization

2007-07-18 Thread Chris Browne
[EMAIL PROTECTED] (Richard Huxton) writes: > Jyoti Seth wrote: >> Hello , >> I have two postgres databases on different linux servers. Postgres >> database >> on one server has some tables that needs to be synchronized from the other >> postgres database . What should be the best method for this.

Re: [SQL] Vacation days

2007-06-26 Thread Chris Browne
[EMAIL PROTECTED] (Wei Weng) writes: > On Monday 25 June 2007 15:22, Susan Young wrote: >> Hi Wei, >> That's OK - Enjoy! >> Susan >> >> Wei Weng wrote: >> > Can I take next week off? >> > >> > Thanks! >> > >> > Wei > > hi, susan, a change of plan. :) > > Instead of the whole week, I just wanted to

Re: [SQL] Index Anding

2007-02-01 Thread Chris Browne
[EMAIL PROTECTED] (Andrew Sullivan) writes: >> Does postgres provide 64 bit support? If so is there a precompiled 64 >> bit version for AIX? I have the 32 bit GCC and can compile 32 bit. 64 >> bit GCC I have not gotten stabilized. (I cold use a tip in that >> direction if anyone lese has experience

Re: [SQL] Database recovery in postgres 7.2.4.

2006-11-02 Thread Chris Browne
"Santosh" <[EMAIL PROTECTED]> writes: > Hi All. > > My setup is as follows: > OS: Sun Solaris 5.8. > Postgres: 7.2.4 > > I have very large database, which contain 15 tables and each table is > contain more than 10,00,000 records. > > My application is parsing text data files and inserting records i

Re: [SQL] Is this a bug? Deleting a column deletes the constraint.

2006-10-12 Thread Chris Browne
[EMAIL PROTECTED] (Joe) writes: > On Thu, 2006-10-12 at 01:25 -0400, Tom Lane wrote: >> It does seem like this is wrong, in view of SQL92's statement about >> ALTER TABLE DROP COLUMN: >> >> 4) If RESTRICT is specified, then C shall not be referenced in >> the of any view desc

Re: [SQL] SQL generator

2006-07-25 Thread Chris Browne
"Bit Byter" <[EMAIL PROTECTED]> writes: > I would like to know what the underlying SQL statement will look > like, so that I can use this knowlege to build a generic parser that > creates SQL statements from the "English like" text, using the > syntax I described above. I seem to recall that Lotus

Re: [SQL] Sequences, values still increased

2006-07-19 Thread Chris Browne
Paul Maier <[EMAIL PROTECTED]> writes: > Hello everybody, > > Why does... > > BEGIN; > SELECT nextval('test.test_seq') AS id; > ROLLBACK; > > ...still increase the sequence after aborting the transaction? This > nextval-command should be reverted after rolling back, right? Same with an > ABORT: > >

Re: [SQL] MS-SQL<->Postgres sync

2006-07-10 Thread Chris Browne
[EMAIL PROTECTED] (Scott Marlowe) writes: > On Mon, 2006-07-10 at 11:25, Andrew Sullivan wrote: >> On Mon, Jul 10, 2006 at 11:27:52AM -0400, Kevin Bednar wrote: >> > Looking to keep 2 databases in sync, at least semi-realtime if possible, >> > although running a batch update every x mins wouldn't

Re: [SQL] Alternative to serial primary key

2006-07-07 Thread Chris Browne
darcy@druid.net ("D'Arcy J.M. Cain") writes: > And even given all of that, I would probably still use serial. >> and has been recommended. But having a hash function over the address >> column as the primary key means I can always regenerate my primary key > > Danger, Will Robinson. The phrase "re

Re: [SQL] Alternative to serial primary key

2006-07-06 Thread Chris Browne
[EMAIL PROTECTED] (Andrew Sullivan) writes: > On Thu, Jul 06, 2006 at 10:16:42PM +1200, David Clarke wrote: >> column that is calculated from another column in the table but I think >> it would still be more effective than a serial id. > > There is the problem that the hash is not proved unique (in

Re: [SQL] Table design question

2006-06-01 Thread Chris Browne
"codeWarrior" <[EMAIL PROTECTED]> writes: > I never use anything other than "id SERIAL NOT NULL PRIMARY KEY" for my > PKEY's -- as an absolute rule -- I guess I am a purist... Everything else > (the other columns) can have unique constraints, etcetera and be FOREIGN > KEYS, etc... > > Try INSER

Re: [SQL] unique constraint instead of primary key? what

2006-02-10 Thread Chris Browne
gry@ll.mit.edu (george young) writes: > On 9 Feb 2006 08:22:59 -0800 > "BigSmoke" <[EMAIL PROTECTED]> threw this fish to the penguins: > >> If my tables have one or more UNIQUE constraints/indices, I still add a >> "id SERIAL PRIMARY KEY" field to most of my tables. This makes >> referencing easier

Re: [SQL] Does VACUUM reorder tables on clustered indices

2005-12-21 Thread Chris Browne
[EMAIL PROTECTED] ("Jim C. Nasby") writes: > On Wed, Dec 21, 2005 at 12:34:12AM +0100, [EMAIL PROTECTED] wrote: >> Hi, >> >> Utilize CLUSTER; (after vacuum) to reorder the data. > > Why would you vacuum when cluster is just going to wipe out the dead > tuples anyway? There is one reason to VACUUM

Re: [SQL] changing a column's position in table, how do you do that

2005-09-27 Thread Chris Browne
[EMAIL PROTECTED] (Ferindo Middleton Jr) writes: > Is there a way to change the position attribute of a column in a > table? I have data that I need to import into various tables in my db > on a consistent basis... I usually us e the COPY ... FROM query but I > can't control the -order- of the fiel

Re: [SQL] add column if doesn't exist

2005-09-27 Thread Chris Browne
[EMAIL PROTECTED] ("Brandon Metcalf") writes: > p == [EMAIL PROTECTED] writes: > > p> Brandon Metcalf wrote: > p> > Is there a way to check for the existence of a column in a table > p> > other than, say, doing a SELECT on that column name and checking the > p> > output? > > p> SELECT * FROM

Re: [SQL] Possible to delete record from all tables at the same time?

2005-09-26 Thread Chris Browne
[EMAIL PROTECTED] writes: > Is it possible to delete a record from all tables in the database at > the same time, without having to execute a separate "DELETE" statement > for each table? > > I have a situation where I need to delete user records from our system. > The user account information is s

Re: [SQL] stored procs in postgresql

2005-09-24 Thread Chris Browne
[EMAIL PROTECTED] writes: > I have been having some trouble with plsql stored procs in postgres in > that I can > make a table name a variable in the stored proc. Is there some > special way to make this happen that I am unaware of? > > For example, I want to do something like: > > stored_proc(in

Re: [SQL] Tidying values on variable instantiation

2005-08-26 Thread Chris Browne
[EMAIL PROTECTED] ("Bath, David") writes: > Question(s): > * Am I being realistic, or should I grit my teeth and clone code from > trigger to trigger and column to column? > * Is this something I should try and do using domains, types and > cast functions from "text" or some horrible combinatio

Re: [SQL] Tidying values on variable instantiation

2005-08-26 Thread Chris Browne
[EMAIL PROTECTED] ("Greg Patnude") writes: > Data validation and purification should be performed at the > application layer -- you should format your data appropriately > BEFORE trying any INSERT/UPDATE operations. It seems to me that one might create some stored functions that can do some valida

Re: [SQL] REINDEX DATABASE

2005-07-27 Thread Chris Browne
[EMAIL PROTECTED] (Achilleus Mantzios) writes: > O Chris Browne έγραψε στις Jul 26, 2005 : >> You can get a savings of about 4% of the space, but at the cost of >> taking an appreciable outage during which the database is not usable. > > 1st not all database is unusable, durin

Re: [SQL] REINDEX DATABASE

2005-07-26 Thread Chris Browne
[EMAIL PROTECTED] (Achilleus Mantzios) writes: > O Christopher Browne έγραψε στις Jul 26, 2005 : > >> > Hello >> > >> > Would you like to advice to use REINDEX DATABASE on regular basis ? >> > >> > if (yes) >> > how it should be connected with VACUUM FULL ANALYZE which is run >> > regularly ? (rei

Re: [SQL] Make COUNT(*) Faster?

2005-07-07 Thread Chris Browne
[EMAIL PROTECTED] (Varun Mehta) writes: > If I run an EXPLAIN on this query I can see that it is doing a > sequential scan, which seems quite needless, as surely this > information is cached in some secret location. That would in fact surely *NOT* be the case. If you have multiple users performin

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-18 Thread Chris Browne
[EMAIL PROTECTED] (Alain) writes: > Andrew Sullivan escreveu: >> On Thu, May 12, 2005 at 01:07:00PM -0600, [EMAIL PROTECTED] wrote: >> >>>Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If >>>so, we can write the following query: >> No. What is the purpose of your query? You coul

Re: [SQL] Debet-Credit-Balance Calculation

2005-04-20 Thread Chris Browne
[EMAIL PROTECTED] ("Muhyiddin A.M Hayat") writes: >> There is an easy way to do this; write a plpgsql set returning >> function which adds the balance to the last column of the table. That >> query will always have a cost in both time and memory proportional to >> the size of the table, and the me

Re: [SQL] New record position

2005-03-31 Thread Chris Browne
[EMAIL PROTECTED] ("Greg Patnude") writes: > There's a difference between "natural" order (the location in the > database or on disk) and "record" order (the order specified by the > primary key)... That's well and fine; I could see the "natural order" in which data is returned varying over time i

Re: [SQL] New record position

2005-03-30 Thread Chris Browne
[EMAIL PROTECTED] writes: > Why it? I can't undestand why the new record location was change. Shouldn't it > apper at the LAST record??? > What need I do?? SQL only imposes an order on the return set if you add an "ORDER BY" clause. You can't expect any particular order to either recur or NOT rec

Re: [SQL] LIKE on index not working

2004-07-22 Thread Chris Browne
[EMAIL PROTECTED] ("Chris Cox") writes: > Hi all, > > For some reason I just can't get this to use the index for the following > query. I'm using PostgreSQL 7.3.4. > > Here's the details (let me know if you need anymore information to provide > any assistance): > > Indexes: person_pkey primary key

Re: [SQL] IMPORT TOOL

2004-03-11 Thread Chris Browne
[EMAIL PROTECTED] (Louie Kwan) writes: > Do anyone of you aware of any PG import tool same as SQL*LOADER in ORACLE > > We are doing some DataWarehouse work and need to import a large set of data > from csv files. > > We are trying a import tool from ems-hitech.com, but I have troubles when > loadin