I have a tree structure in a table and it uses materialized paths to allow me to find children quickly. However, I also need to sort the results depth-first, as one would expect with threaded forum replies.
id | parent_id | matpath | created
----+-----------+---------+----------------------------
2 | 1 | 1...
Im looking at an application where I will be doing quite a few SELECTs where I am trying to find column_a = x AND column_b = y.
Is the correct to create that index that something like the following?
CREATE INDEX index_name ON table (column_a, column_b)
...
Forgot to make a backup. Now I have harddrive with databases and new system with empty postgres. Can I somehow restore databases? by simple copy of files etc?
...
Code
The following code calculates the slope and intercept for a linear regression against a slathering of data. It then applies the equation y = mx + b against the same result set to calculate the value of the regression line for each row.
How can the two queries be joined so that the data and its slope/intercept are calculated withou...
I am trying to store in a postgresql database some unique identifiers along with the site they have been seen on. I can't really decide which of the following 3 option to choose in order to be faster and easy maintainable. The table would have to provide the following information:
the unique identifier which unfortunately it's text
the...
I have 2 exactly same databases on 2 different machines(with different data that is), and I want to transfer contents of one table to the table from the other database, how do I do that from PgAdmin? I'm new to PostgreSQL Database, I'd do that easily with mysql phpmyadmin just export sql and I'd get text file with bunch of insert into st...
I have a column in a PostgreSql database that is defined with type boolean[]. I wish to map this to a Java entity property using Hibernate 3.3.x. However, I cannot find a suitable Java type that Hibernate is happy to map to. I thought that the java.lang.Boolean[] would be the obvious choice, but Hibernate complains:
Caused by: org.hiber...
Hi,
Suppose I have two tables:
Group
(
id integer primary key,
someData1 text,
someData2 text
)
GroupMember
(
id integer primary key,
group_id foreign key to Group.id,
someData text
)
I'm aware that my SQL syntax is not correct :) Hopefully is clear enough. My problem is this: I want to load a group record...
I am importing data from a CSV file. One of the fields has an accent(Telefónica O2 UK Limited). The application throws en error while inserting the data to the table.
PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xf36e6963
HINT: This error can also happen if the byte sequence does not match the
encoding expected by the ...
ok im trying to upload this csv file onto my table in pgsql
but im getting this error
ERROR: invalid input syntax for integer: "mlname,mfname,slname,sfname,address,postalcode,membershiptype,hphone,email"
CONTEXT: COPY members2, line 1, column id: "mlname,mfname,slname,sfname,address,postalcode,membershiptype,hphone,email"
i really...
The name pretty much says it all. Right now I'm using Squirrel - it crashes frequently and suffers from memory problems (I've tried increasing the heap size). I don't need anything particularly fancy or full-featured - just something that won't take up 2.4 GB of RAM to store a 1.5 million line, 8 column result set.
...
I'm working on a web-based business application where each customer will need to have their own data (think basecamphq.com type model) For scalability and ease-of-upgrades, I'd prefer to have a single database where each customer gets a filtered version of the data. The problem is how to guarantee that they stay sandboxed to their own ...
I've always used either auto_generated or Sequences in the past for my primary keys. With the current system I'm working on there is the possibility of having to eventually partition the data which has never been a requirement in the past. Knowing that I may need to partition the data in the future, is there any advantage of using UUID...
I need to update some timestamp columns in a table in a PostGres (8.3) database.
My query (simplified) look like this:
update table1 set dateA = dateA + interval '10 hours' where id = 1234;
This is part of a script and there's a lot to update so my preference is to use bind variables, rather than to have to build the query string eac...
Hi,
I have the following 2 tables:
items:
id int primary key
bla text
events:
id_items int
num int
when timestamp without time zone
ble text
composite primary key: id_items, num
and want to select to each item the most recent event (the newest 'when').
I wrote an request, but I don't know if it could be written more efficient...
Hi,
i have two tables:
CREATE TABLE "public"."auctions" (
"id" VARCHAR(255) NOT NULL,
"auction_value_key" VARCHAR(255) NOT NULL,
"ctime" TIMESTAMP WITHOUT TIME ZONE NOT NULL,
"mtime" TIMESTAMP WITHOUT TIME ZONE NOT NULL,
CONSTRAINT "pk_XXXX2" PRIMARY KEY("id"),
);
and
CREATE TABLE "public"."auction_values" (
"id" NUMERIC DEFAU...
POSTGRESQL 8.4.3 - i created a function with this signature
CREATE OR REPLACE FUNCTION logcountforlasthour()
RETURNS SETOF record AS
realised i wanted to change it to this
CREATE OR REPLACE FUNCTION logcountforlasthour()
RETURNS TABLE(ip bigint, count bigint) record AS
but when i apply that change in the query tool it isnt accept...
I have been tasked with migrating an existing mature ASP.NET 2.0 web site to NHibernate, Mono and MySQL or postgres. I am somewhat confused as how the membership provider salts the passwords. If I make the switch and use the MySQL membership provider (outlined in this question) or AspSqlProvider, will the existing users be able to logi...
I screwed up and created a column as a varchar(255) where that is no longer sufficient. I've read that varchar has no performance benefits over text on Postgres, and so would like to convert the varchar to a text column in a safe way that preserves the data.
What's the best way for me to do this?
...
What is postgresql_psycopg2 ? Difference from postgresql ?
...