postgresql

Using Java, I upload an image to postgres DB size is 4000. But when I download it, the size is 8000.

Here is the latest code. I wanted to try something different but I am still getting the same results. I am using postgres DB and I created a column called file with a data type bytea. The image does get uploaded to the DB (I can see it in there when I view the table's data). I tried it with several images. The size appears to be correc...

How to create production database sample for testing?

Is there a tool (for PosgreSQL, ideally), which can make a small, but consistent sample of a big database? The this is we need a testing database, but we don't want to fully copy the production one. First, because it is too big and second, the nature of testing implies that the testing database will be recreated several times in the pro...

Is there an ASP.NET MVC book which uses NHibernate for ORM?

I'm learning ASP.NET MVC but I prefer to use OS X and MonoDevelop(especially Mono 2.8 is out now, supports ASP.NET MVC 2). Is there an ASP.NET MVC book that also teach how to use NHibernate and Postgresql or MySQL? (No Sql Server, as that would entail me installing vmware/parallels in OS X) ...

SQL Server Express alternatives beyond 2GB limit

In our project (which is fully developed using .NET), we use a medium sized database about 2 GB in size. Currently we are using SQL Express edition; How do the alternates for SQL Server Express perform? I am mainly considering MySQL and PostgreSQL. (Windows 7 x86, x64) Is there any compelling advantage to using MySQL or PostgreSQL? W...

PostGres string data type storage allocation

Hi We are running PostGres 8.3.3 and the documentation (http://www.postgresql.org/docs/8.3/static/datatype-character.html) leaves me with a few questions about how storage is allocated. For the purposes of this discussion I'd like to stick to assuming a character = 1 byte. I understand that character(n) blank pads so you always have n...

Does pgpool run on cygwin

Hi, Do you know if pgpool run with cygwin on windows ? If it does, do know any tutorial ? Thanks, ...

Mapping BPCHAR in JPA

One of the properties in my entity is mapped to bpchar (BLANK PADDED CHAR) string. @NotNull @Column(name = "property", columnDefinition = "bpchar") private String property; When I save entity and load back, then my property is padded with spaces, that is correct from the database point of view. But I want to work in code with trimmed...

Rails: An efficient method to match subdomains in the database?

We allow users to add domains to an active record model such as User.domain and find the users by domain using User.find_by_domain. In the future we want to allow users to enter *.example.com as their domain and allow User.find_by_subdomain('sub1.example.com') and User.find_by_subdomain('sub2.example.com') to work. However we also want ...

Postgres injection tools

Hi all, I am looking for tools that I can use to audit the security of my database at the moment. Does anyone have any resources on this? I am running postgres, so that will take precedence. ...

Need help with a SQL query that returns the lasts records matching a certain criteria.

I have the following table: CREATE TABLE "posting" ( "id" integer NOT NULL PRIMARY KEY, "amount" real NOT NULL, "balance" real NOT NULL, "account_id" integer NOT NULL REFERENCES "account" ("id"), "asset_type_id" integer NOT NULL REFERENCES "asset_type" ("id") ) For this table, I manually generate ids in a w...

PosgreSQL nested queries perfromance

Are there significant performance issues when using nested(2 level deep at max) queries in PostgreSQL? I use version 8.4.2 I am asking because I am planning to use quite a lot of those soon on a busy website.. ...

Complex Group By Query (recursive?)

Hi, sorry for the title but I'm not sure how I should call it. I'm using PostgreSQL 8.3 and would be fine with non-ansi query proposals. Suppose this schema: TimeEntries id - int entry_date - date tracked_seconds - int project_id - int projects id - int name - string path - st...

PostgreSQL alerts to C++ application

Hi Folks, My C++ application has to receive alerts from the PostgreSQL database, as soon as any data is modified in tables. Can you please advice to implement this in best possible way. Please note that alert information would also need to have the information of the data that has been changed. Thanks, Gtk ...

cumulative sum per day in rails&postgresql

Hi, Ive got a table 'donations' which is filled (by users) on a daily basis. I would like to create a graph that shows the cumulative number of donations per day. So, table donations: id created_at 1 19/01 2 20/01 3 20/01 4 21/01 Should become: [1,3,4] How to do this with rails3&postgresql? Thanks in advance ...

Postgres - out of memory on looping insert

Hi all, I'm parsing an XML file with a few thousand elements in it for insertion into a sql database. Everything works fine with sqlite, but postgres dies on me with this error: PGError: ERROR: out of shared memory I was monitoring locks, and it looks like there's a lock for each insert statement, and although I'm just looping over...

pgAdmin 1.12.0 and sql-assistant doesn't work together

Since upgrading to final 9.0 postgresql latest sql-assistant (5.1.10) doesn't work with pgAdmin 1.12.0 Any ideas why so? Or anybody knows any similar to sql-assistant software to work with postgresql 9.0? ...

Rails and Heroku PGError: column does not exist

This page I have been developing for my app has been working fine locally (using sqllite3) but when I push it to Heroku, which uses PostgreSQL I get this error: NeighborhoodsController# (ActionView::Template::Error) "PGError: ERROR: column \"isupforconsideration\" does not exist\nLINE 1: ... \"photos\" WHERE (neighborhood = 52 AND is...

foreach %dopar% + RPostgreSQL

I am using RPostgreSQL to connect to a local database. The setup works just fine on my Linux machine. R 2.11.1, Postgres 8.4. I was playing with the 'foreach' with the multicore (doMC) parallel backend to wrap some repetitive queries (numbering a few thousand) and appending the results into a data structure. Curiously enough, it works i...

PostGIS: bounding box of a multipolygon

SELECT id, ST_Box2D(areas) AS bbox FROM mytable; In this example, the table "mytable" contains two columns: "id" is the unique id number of the row and "areas" is a geometry field containing one MULTIPOLYGON per row. This works fine for multipolygons containing only one polygon, but some rows have polygons very spread apart, hence t...

Manual inserts on a postgres table with a primary key sequence

Hi guys! I'm converting a MySQL table to PostgreSQL for the first time in my life and running into the traditional newbie problem of having no auto_increment. Now I've found out that the postgres solution is to use a sequence and then request the nextval() of this sequence as the default value every time you insert. I've also read that...