Re: [SQL] Formatting current_time output

2002-10-03 Thread Josh Berkus
x27;t found? Um, what's wrong with: SELECT to_char(current_time, 'HH12:MI AM'); ? (See "Formatting Functions" under "Functions and Operators" in the User's Guide) -Josh Berkus ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] indexing on char vs varchar

2002-10-02 Thread Josh Berkus
Beth, Oh, and you should take this sort of question to the new performance list: [EMAIL PROTECTED] -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Can Postgres cache a table in memory?

2002-10-04 Thread Josh Berkus
oin the PGSQL-PERFORMANCE mailing list and post this question there: [EMAIL PROTECTED] message: "subscribe" -Josh Berkus ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Get A Tree from a table

2002-10-07 Thread Josh Berkus
in far more depth than I want to here; 2) Explore the tree module in /contrib in your Postgresql source. I understand from Joe Conway that in 7.3, you will have another choice, as Postgres will offer support for Oracle's tree-like "IS CONNECTED BY" expression. Good luck! -Josh Berkus P.

Re: [SQL] foreign key problem

2002-10-07 Thread Josh Berkus
s possible that your "ON DELETE CASCADE" trigger got wiped out somehow. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] foreign key problem

2002-10-07 Thread Josh Berkus
Laurette, > How is this possible? I've tried to reproduce this, but haven't been able > to yet. This has happened to use several times. Oh, forgot question 2: SELECT version()? -- -Josh Berkus Aglio Database Solutions San Francisco ---(

Re: [SQL] Temporary tables and indexes

2002-10-08 Thread Josh Berkus
e indexes would be dropped as well. -Josh Berkus ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] [NOVICE] update question

2002-10-08 Thread Josh Berkus
David, I'm sorry, you just don't seem to be at the "self-help" stage. I strongly reccommend that you hire a database consultant to help you. -Josh Berkus DAVID KUCHARSKI <[EMAIL PROTECTED]> wrote: > the result set of the view is 3628 lines. It would be >

Re: [SQL] IN, EXISTS or ANY?

2002-10-08 Thread Josh Berkus
Keith, > >>But EXISTS is an entirely different animal which is often faster > >>... isn't that in the FAQ? > > > There is no reference to EXISTS in the SELECT documentation?? > > Is this explained somewhere else? Hmmm found this using the Index for the online docs: http://www.us.postgr

Re: [SQL] Temporary tables and indexes

2002-10-08 Thread Josh Berkus
ict if I tried to drop & re-create in the same transaction) without a VACUUM. If you're using 7.1.3, you should upgrade for this reason. -Josh Berkus ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Messy Casts, Is there a better way?

2002-10-15 Thread Josh Berkus
erface code): "interval"(cast($term as varchar) || ' months') This approach makes you do a little more work on the data entry end of things, but speeds up querying considerably. Also, should your company policy change in the future to permit contract terms in weeks o

Re: [SQL] Use of reference table ('look-up-table') and FK constraint

2002-10-16 Thread Josh Berkus
r(10) NOT NULL REFERENCES phone_types(type) -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Multiple Databases

2002-10-23 Thread Josh Berkus
Peter, > Is it possible to create a view using tables from two different > postgresql > servers? No. -Josh Berkus ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] plpgsql cursors : dynamic or static?

2002-10-23 Thread Josh Berkus
ng, that is not a cursor, even though it serves the same purpose. I'm pretty sure it's static, but it would be easy to test ... why don't you give it a try? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)---

Re: [SQL] Sum of Every Column

2002-10-23 Thread Josh Berkus
e > looking elsewhere than SQL to do this for me, such as php (this is for a > web-based report)? You cannot dynamically sum all columns through SQL. You would need to use a procedural language to loop through the columns and create sum clauses for each one. -- -Josh Berkus Aglio Databas

[SQL] Delete/Replace Bug in Functions?

2002-10-21 Thread Josh Berkus
ably, the function and table spec is extremely dense; I'm trying to set up a test case. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Delete/Replace Bug in Functions?

2002-10-21 Thread Josh Berkus
x27;t ever see the extra records. I just tried to set up a test case for this issue, based on much simpler schema. Unfortunately, the bug is not reproduceable in this simple case. Any suggestions on how to reproduce it without dumping you an enitre copy of my *confidentia

Re: [SQL] Messy Casts, Is there a better way?

2002-10-17 Thread Josh Berkus
uld stick with your current schema and custom function. -Josh Berkus ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

[SQL] Missing Review

2002-10-11 Thread Josh Berkus
Folks, Sorry for cross-posting. Somebody sent me a review of the German postgresql book to post at Techdocs. I had a mail server accident, and lost the review and the e-mail address of its writer. Are you out there? Contact me, please. -- -Josh Berkus Aglio Database Solutions San

Re: [SQL] object oriented vs relational DB

2002-10-17 Thread Josh Berkus
of OODBMS in another couple of years. Who knows, ANSI might codify OODB-UML as a standard, and then we'll have something to build on. But until then ... the RDBMS model has been around for 32 years, and the SQL standard for 20, and that a lot of accumulated wisdom to throw away casually. -Josh Berkus ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: Fwd: Re: [SQL] Can I search for an array in csf?

2002-10-21 Thread Josh Berkus
> The application is written in Java, by the way. You should store this data in a sub-table linked through a foriegn key. Period. Messing with arrays will only lead you to heartache ... Try the book "Database Design For Mere Mortals" for a primer on SQL DB design.

Re: [SQL] Can I search for an array in csf?

2002-10-22 Thread Josh Berkus
) However, custom aggregates are slow and Java's array-handling is probably faster. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Can I create working trigger on view

2002-10-18 Thread Josh Berkus
ed on a view: http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/rules.html BTW, you can increase the number of parameters accepted by functions by re-compiling postgres. Also, 7.3 will have 32 as the default. -Josh Berkus ---(end of broadcast)---

Re: [SQL] isAutoIncrement and Postgres

2002-10-18 Thread Josh Berkus
Jim, > Do any existing drivers / database version combinations support the > isAutoIncrement method? What programming language are you referring to? VB? Delphi? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of bro

Re: [SQL] isAutoIncrement and Postgres

2002-10-21 Thread Josh Berkus
ROTECTED] You are unlikely to get an answer on this list. -Josh Berkus ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] datediff?

2002-10-27 Thread Josh Berkus
Erwin, > I read your FAQ: Working with Dates and Times in PostgreSQL with > interest > and was wondering if somebody came up with those datediff and dateadd > functions? > I couldn't find any at techdocs.postgresql.org. I know somebody worked on one. I take it you read the articles on SQL Server

Re: [SQL] datediff?

2002-10-27 Thread Josh Berkus
Erwin, > Thanks for your quick response Josh. > > I wasn't aware of the Postgresql-function DATEDIFF() > The accolade ' is not a problem of course! Whoops! Didn't want to confuse you. What I meant was, a PgSQL function "Datediff" could be easily *written*, except that it would need quoted id

[SQL] BOOLEAN question

2002-10-28 Thread Josh Berkus
thought that I could do this through a MAX(boolean), but as it turns out, MAX(boolean) has not been defined in the standard 7.2.3. distro. I could define MAX(boolean), but I'm wondering if I'm missing something obvious. -- -Josh Berkus Aglio Database Solutions San

Re: [SQL] BOOLEAN question

2002-10-28 Thread Josh Berkus
d get added to the core? I don't see any good reason not to have one. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command

Re: [SQL] BOOLEAN question

2002-10-29 Thread Josh Berkus
esting, SELECT true = ANY ( SELECT boolcol FROM complex query ) Is marginlly faster than SELECT max(boolcol) FROM complex query With a custom MAX(boolean) function. So I'll stick to ANY(). -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] Database Design tool

2002-10-30 Thread Josh Berkus
tive. > > I wonder if I can find a standalone java query analyzer package. Does > anyone know? I believe that Red Hat offers the query analyzer as a download. Check their site. -- -Josh Berkus Aglio Database Solutions San Francisco ---

Re: [SQL] Database Design tool

2002-10-30 Thread Josh Berkus
.x clusters. === -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] making queries more effecient

2002-11-01 Thread Josh Berkus
T INTO "VisitorPointer839" ("VisitorID") SELECT "VisitorID" FROM ( SELECT DISTINCT ON ("VisitorID") "VisitorID","Type" FROM "ProgramEvent" WHERE "ProgramID" = 10 ORDER BY "VisitorID",&q

Re: [SQL] making queries more effecient

2002-11-01 Thread Josh Berkus
s of ANSI SQL. > And Just writing it out straight. > > insert into VisitorPointer839 ("VisitorID") > select VisitorID > from ProgramEvent > Where ProgramID = 10 > and Type = 0 > group by VisitorID This just gives him a list of all VisitorIDs with a Type = 0, most recent or not. > Thanks > Chad "I wanna be Josh when i grow up" Thompson Thanks. But heck, I'm only 32! I'm not grown up yet! -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Timezone issue with date_part

2002-11-02 Thread Josh Berkus
Of course, it could be solved with a DAY/WEEK subtype, but I've already advocated for that. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropria

Re: [SQL] counting text matches - any recipes?

2002-11-04 Thread Josh Berkus
t string. Potentially slower than #1, but easier to implement. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [GENERAL] [SQL] Database Design tool

2002-11-05 Thread Josh Berkus
Thomas, > > DBVisualizer is pretty good. > > Is there a page at PostgreSQL.org where all these links are listed? > I've been saving each bit of mail that goes by on this thread...but > a page on Pg would be very nice. ;-) I was planning on writing an article; so far, I have a list of about 14 i

Re: [SQL] Copying a rowtype variable.

2002-11-05 Thread Josh Berkus
res lets you slack on this, but it would be worth trying to see whether that has an effect on the problem. Another thing to try is, instead of a simple variable assignment, SELECT current_row INTO previous_row; ... and see if that works. I'll tinker later today; there has to be a way

Re: [GENERAL] [SQL] Database Design tool

2002-11-05 Thread Josh Berkus
a few more tools to look at. Boy, do we have an answer for the folks who complain "there are no GUI tools for Postgres". I'll also have Justin update his list on Techdocs when I write my article. -- -Josh Berkus Aglio Database Solutions San Francisco -

Re: [SQL] PLpgSQL FOR IN EXECUTE question

2002-11-07 Thread Josh Berkus
Chris, > FOR this_record IN > EXECUTE ''SELECT '' > || quote_ident($1) > || ''FROM '' > || quote_ident($2) > LOOP > list := list || '', '' || this_record.$1 ; > END LOOP; > > As expected, accessing a field via this_record.$1 > does not work. > Can it be done otherwise?

Re: [SQL] Permission on insert rules

2002-11-08 Thread Josh Berkus
Functions has been addressed in 7.3. However, I am not sure about permissions for updatable views. Tom, Bruce? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unreg

Re: [SQL] Permission on insert rules

2002-11-11 Thread Josh Berkus
Robert, > If the functions can fire as there creator instead of there caller, > then > I would think as long as the creator has insert/update views on the > base > table, you should be able to do updateable rules and give only > permissions to the view for the caller. (Though maybe you have to use

Re: [SQL] bigger problem

2002-11-11 Thread Josh Berkus
th your configuration of Oracle import. See your Oracle documentation; we cannot help you here. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Generating a cross tab (pivot table)

2002-11-11 Thread Josh Berkus
s in "SQL for Smarties". I will write a PostgreSQL implementation in a later article. -Josh Berkus ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Permission on insert rules

2002-11-11 Thread Josh Berkus
# where user_id = OLD.user_id; See the online docs, under Server Programming, for how to use the RULES system. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an

Re: [SQL] Permission on insert rules

2002-11-12 Thread Josh Berkus
he view 4) A copy of your database session where your update is denied, including the exact error message received. Without that information, no futher help is available. -Josh Berkus ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Inconsistent or incomplete behavior obverse in where

2002-11-12 Thread Josh Berkus
vailable. Production > for us is next spring, so maybe we'll be okay on this one. > This approach would certainly allow our development team to > right their code one way. 7.3 final is expected before December. -- -Josh Berkus ---(end of broa

Re: [SQL] Permission on insert rules

2002-11-13 Thread Josh Berkus
Luis, > There's any way to insert data inside the tables, using the > functions, called by the rules, without giving direct access to the > user ? > I don't know, using a trigger or any kind of structure !!?? Not until 7.3. Which is due out soon ... a couple of weeks,

Re: [SQL] System´s database table

2002-11-13 Thread Josh Berkus
Pedro, > I´m looking for the name of the table that contains all databases in my system. I already see this in the postgre manual, but i´m forgot where pg_database -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadc

Re: [SQL] System´s database table

2002-11-13 Thread Josh Berkus
Jean-Luc, > While we are on the subject, > is there any ERD of the system's table somewhere? Don't know ... but the system tables are about to change in 7.3. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)---

Re: [SQL] Inconsistent or incomplete behavior obverse in where

2002-11-12 Thread Josh Berkus
someone else will respond to your message as well. I'll re-phrase one of your questions for the Hackers list: QUESTION: Is there any way we could distinguish between literals and column references when processing operators? That is, while we would *not* want to implicitly convert a

Re: [SQL] Updating a table column with ref integrity

2002-11-15 Thread Josh Berkus
r database to file. Backup. Edit the file. Re-create and re-load the database. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] INDEX PROBLEMS ?

2002-11-16 Thread Josh Berkus
Alex, > On postgres 7.2.3 I have found what follows: > > explain select * from documents where iddoc>1; > > Seq Scan on lotti (cost=0.00..831.79 rows=26783 width=98) > > EXPLAIN > explain select * from documents where iddoc=1; > > Index Scan using lotti_pkey on lotti (cost=0.00..2.26 rows=1

Re: [SQL] Proposal of hierarchical queries, a la Oracle

2002-11-16 Thread Josh Berkus
tgreSQL 7.3, as a /contrib module, by Joe Conway. Download 7.3b5 now if you can't wait; Joe would like more people to test his module, anyway. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command

Re: [SQL] Trees: maintaining pathnames

2002-11-17 Thread Josh Berkus
ent, open ridicule, most welcome. thanks. This is a fine implementation using the adjacency list model of tree design. However, I think you may find that the string-based tree implementation in /contrib/ltree is more suited to your purposes, and easier to maintain. -Josh Berkus --

Re: [SQL] trying to learn plpqsql... so please forgive..

2002-11-20 Thread Josh Berkus
the screen. Can you break down, in more detail, what you're *trying* to do? It can probably be done, but I'm still not clear on what you're attempting. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once

Re: [SQL] trying to learn plpqsql... so please forgive..

2002-11-20 Thread Josh Berkus
return values to the calling interface. Now, what you could do is replace the whole insert with a function, doing: SELECT add_cust( name, address, phone, credit_card); Which does the inserting and returns the new id to the client.This is a solution I frequently use in my web apps. -Josh Be

Re: [SQL] Trees: maintaining pathnames

2002-11-22 Thread Josh Berkus
le to hold the pathnames should cure your "cascading trigger" problem. -Josh Berkus ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Josh Berkus
x27;d want to use Triggers or Constraints etc. There are, IMHO, some things Rules are better for, and some things Triggers are better for. I tend to use all Triggers except for updatable views, simply because using a mix of Rules and Triggers can be very hard to keep track of, but YMMV. --

Re: [SQL] Rules/Trigges Trade-offs

2002-12-06 Thread Josh Berkus
h a table check on > > the new data impractical, so you'd want to use Triggers or Constraints > > We have changed ordering in 7.3 where I think INSERT rules are _after_ > the insert. How would that work? What if I want to reject the insert? -- -Josh Berkus Aglio Database S

Re: [SQL] Rules/Trigges Trade-offs

2002-12-09 Thread Josh Berkus
ion if necessary, otherwise inserts. It's tricky, but probably the best way to get trigger + rule functionality at once. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through U

Re: [SQL] Rules/Trigges Trade-offs

2002-12-09 Thread Josh Berkus
will see if RECORD works too. I wonder if that would eliminate the problem I ran into where I had dropped and recreated the table. The function barfed since the OID for the user defined type "test" did not exist. > > This will work slick. Thanks! > > >>&g

Re: [SQL] Rules/Trigges Trade-offs

2002-12-09 Thread Josh Berkus
n 7.4 devel by accident. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get

Re: [SQL] Problem with a lookup table! Please help.

2002-12-09 Thread Josh Berkus
se post your table definitions as SQL statements. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] trigger to maintain relationships

2002-12-11 Thread Josh Berkus
W. You're also missing the parts of a PLPGSQL procedure. What you want is: create function pr_tr_i_nodes() returns opaque > as ' DECLARE v_ancestor INT; BEGIN SELECT ancestor_id INTO v_ancestor FROM ancestors WHERE ancestors.node_id = NEW.parent_id; INSERT INTO ancestors VALUES ( NEW.no

Re: [SQL] A PL/PgSQL Question

2002-12-13 Thread Josh Berkus
atement is a much better than a RAISE EXCEPTION > statement? Not that I have encountered, but YMMV. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregi

Re: [SQL] UPDATE comparing dates and non-dates data

2002-12-13 Thread Josh Berkus
; from the aforementioned > SELECT, leaving the non-coincident dates in blank and filling the rain data > of the coincident dates. Is this possible? How? I don't think this is the best method to find missing dates. However, I'm a little confused as to what you consider a "mis

Re: [SQL] Postgres V/S Oracle

2002-12-17 Thread Josh Berkus
Prashanth, > I am working in the database area for the first time. > My work is related to Postgres. Now comparatively i am familiar with > the Postgres. > I am looking for any document on differences between postgres and > oracle w.r.t SQL syntax and built-in functions. > Any pointers in this dir

Re: [SQL] pl/pgsql question

2002-12-18 Thread Josh Berkus
Tim, > That loop apparently does not find any matching rows, which would > have been inserted just before this row was, inside the same > transaction. > > It was successfully finding those rows before, when the trigger was > AFTER INSERT. If I manually select those rows after the query is > commi

Re: [SQL] count(*) optimization

2003-01-08 Thread Josh Berkus
#x27;ve found pgAdminII to be sluggish on a large, busy network because MS-ODBC is quite vulnerable to traffic conflicts. And phpPgAdmin, at least several versions ago, had a tendency to issue a seperate query for each single bit of information, mySQL-style (they may have fixed

Re: [SQL] Table Design Questions

2003-01-10 Thread Josh Berkus
Chad, > I am trying to come up with an efficient table design > that describes a fantasy character that meets the > following criteria: Believe it or not, this is the first "D&D" question I've seen on this list. > CREATE TABLE ATTRIBUTES ( > CHAR_ID INT PRIMARY KEY NOT NULL, > ATTR

Re: [SQL] function does not exist

2003-01-10 Thread Josh Berkus
Dave, A trigger function does not take variable parameters, gets its data from the NEW or OLD records, and returns OPAQUE with the RETURN NEW statement. Please check out the documentation on writing PL/pgSQL triggers under Procedural Languages in the online docs. -Josh Berkus

Re: [SQL] Crosstab-style query in pure SQL

2003-01-13 Thread Josh Berkus
procedural logic for a dynamic set of parameters. However, the above is set up for numeric values (i.e. one multiplies the grid number by the value to add into calculations) and will not work for your varchar-returning query. You could, however, constuct the grid with NULLs and '' str

Re: [SQL] to_date confusion

2003-01-13 Thread Josh Berkus
Richard, > I'm confused. How do I get the integer 10102 to come in as the date > 2002-01-01? Hmmm ... isn't this an old post, repeating? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP

Re: [SQL] query speed joining tables

2003-01-13 Thread Josh Berkus
r by user_login.last_login desc; Use a "WHERE EXISTS" clause instead of "IN". -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate

Re: [SQL] Performance of request of type WHERE ... IN ( ... )

2003-01-15 Thread Josh Berkus
Th, > > I have performance problem of an request of type ... WHERE ... IN ( > ... ). > > How to improve performance of this type of request when a group of > id in the > > 'in' is important. > > Try WHERE ... EXISTS (...). The explanation of the difference btw. IN and EXISTS is in the PostgreSQL

Re: [SQL] query speed joining tables

2003-01-15 Thread Josh Berkus
database, and if it's a low-budget project destined to be thrown away in 3 months, then go for it. If, however, you expect this database to be around for a while, you owe it to yourself and your co-workers to design it right. If you want an education on database normalization, pi

Re: [SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Josh Berkus
E FUNCTION to_year (timestamp) RETURNS varchar AS 'SELECT to_char($1, '''');' LANGUAGE 'sql' WITH (ISCACHABLE, ISSTRICT) (above is 7.2.3 syntax) Then use the to_year function in place of to_char for creating your index. -Josh Berkus -

Re: [SQL] query speed joining tables

2003-01-15 Thread Josh Berkus
;' || $2 END ' LANGUAGE 'sql'; --create aggregate with html between items CREATE AGGREGATE br_list ( BASETYPE = text, SFUNC = br_cat, STYPE = text, INITCOND = '' ); --create aggregate with commas between items CREATE AGGREGATE comma_list ( BASETYPE = text, SFUNC = comma_cat, STYPE = text, INITCOND = '' ); -Josh Berkus ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] RFC: A brief guide to nulls

2003-01-15 Thread Josh Berkus
HERE NOT (co_id=1 OR co_id=2 OR co_id=null OR co_id=3...) > WHERE NOT (... OR null OR ...) > WHERE NOT (null) > WHERE null I'd suggest that you do not want to give readers an example that contains NOT IN (subselect). There are almost no cricumstances under

Re: [SQL] query speed joining tables

2003-01-16 Thread Josh Berkus
after the "Database Design > For Mere Mortals". I will read the book. That's a great book, too. Don't start on Pascal until *after* you have finished "database design". -Josh Berkus ---(end of broadcast)-

Re: [SQL] query speed joining tables

2003-01-16 Thread Josh Berkus
> I waited for the book from the local library for more than a month, but only took me less than a hour to scan over the > whole book and grip the multivalued table design idea. Hmmm. I'll need to look at it again. If he's suggesting that it's a good idea to put a delimite

Re: [SQL] "Best practice" advice

2003-01-17 Thread Josh Berkus
nd additionally allow for the promotion of "peripheral" docs to the core easily. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subsc

Re: [SQL] Can I do this?

2003-01-17 Thread Josh Berkus
Wei, > I want to select some data out of database A, and insert them into database B. Is it possible to do in one SQL query? > No. Use a Perl script. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)---

Re: [SQL] Selecting a non-locked row.

2003-01-19 Thread Josh Berkus
t confused by your question. Could you try explaining it another way, possibly with SQL code examples? -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Selecting a non-locked row.

2003-01-19 Thread Josh Berkus
, you would have to set a tuple lock with something longer lasting than select for update, and arrange to drop it if the connection dies. but it's still my preferred solution) -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Group By Error Text

2003-01-19 Thread Josh Berkus
in an aggregate function. Should a > change be made to the error text? Nope. The error message is exactly correct. If you didn't want to GROUP BY jobno, then what you actually wanted to query was: SELECT count(jobno) FROM drawing_register; -- -Josh Berkus Aglio D

Re: [SQL] performance question

2003-01-20 Thread Josh Berkus
Moritz, There is a performance mailing list at: [EMAIL PROTECTED] --Josh ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] performance question

2003-01-20 Thread Josh Berkus
Moritz, > I'm sorry, I didn't realize this, it is certainly closer to what I > need. > Next time I'll look better (google brought up references to this > list, so > I subscribed here). Hey, there are 18 active lists now ... we don't expect anyone to get the

Re: [SQL] Function for adding Money type

2003-01-24 Thread Josh Berkus
David, > Are there functions for adding and subtracting this type from itself? > Or is there a simple way to do it? The MONEY type is depreciated, and should have been removed from the Postgres source but was missed as an oversight. Use NUMERIC instead. -- -Josh Berkus Aglio Da

Re: [SQL] Problem with query

2003-01-28 Thread Josh Berkus
Ricardo, For future notice, there is another mailing list, PGSQL-PERFORMANCE, devoted to questions like yours. > select * from llamada where fecha='20030127' and tipo=1 and tiempo>0 > and gwdes like '64.7.127.14%' order by hora desc; > > It's very slow, it takes approximately 6 minutes to show m

Re: [SQL] LONG - Question on dealing w/ numerics

2003-01-28 Thread Josh Berkus
David, > I have a function that is to create a Accounting JOURNAL entry. > The strange thing is the function works for simple entries such as: > Here is the function and I can't seem to figure out what is LOGICALLY > wrong and would produce these results. I'm not sure the problem is with the fun

Re: [SQL] LONG - Question on dealing w/ numerics

2003-01-28 Thread Josh Berkus
David, > Cash - Debit 100 > A/R - Credit 100 > Cash - Credit 100 > A/R - Debit 100 > (Which should have a net affect of 0 on both accounts) > > But here is the resulting balance on accounts, > > Cash Debit Balance 200 > A/R Credit Balance 200 Here may your problem, and it's in the schema

Re: [SQL] which will be faster? w/ or w/o indices

2003-02-07 Thread Josh Berkus
y exploits and one backup-and-restore bug that could make it difficult to recover your database from a backup file. -- Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an

Re: [SQL] Automatic casting

2003-02-06 Thread Josh Berkus
Vicente, > if I try nodo_fecha_activ<= 104422680 then it gives me this error > ERROR: Unable to identify an operator '<=' for types 'numeric' and > 'double precision' This is a known problem that will be fixed in a later version of Postgres. For now, you have to cast. -Josh

Re: [SQL] PL/pgSQL question

2003-02-02 Thread Josh Berkus
. However, implementation is quite cumbersome, and I won't try to detail it here, particularly since that language and method have been obsolesced and would force you to re-write your code when you do upgrade. If this feature is important to you, I strongly recommend that you upgrade to 7.3.1 now.

Re: [SQL] conversi ms-sql7 vs postgresql 7.3

2003-02-10 Thread Josh Berkus
date a ficticious "totals" table with the sum of credits and debits for a particular account. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] PL/PGSQL EDITOR

2003-02-13 Thread Josh Berkus
://www.globecom.se/tora/) functions as a PL/pgSQL editor if you have the Oracle PL/SQL libraries installed. I haven't tried this, myself. I use KDE's Kate. Good luck! -- Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)-

Re: [SQL] Passing arrays

2003-02-13 Thread Josh Berkus
s its elements to a comma-delimited TEXT variable. 2) Build up your query as a dynamic string. 3) Do your query loop as a FOR record IN EXECUTE dynamic_query_string -- Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP

Re: [SQL] rownum

2003-02-13 Thread Josh Berkus
Chester, > sorry about this - braindead and cannot find in doc. what's pg's > rownum pseudo-column or function name that returns the record number of > a set? There isn't one, unless there's something in /contrib that you can build. -- Josh Berkus Aglio Dat

<    1   2   3   4   5   6   7   8   9   >