Skip site navigation (1) Skip section navigation (2)

Re: Help request to improve function performance

From: Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>
To: Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help request to improve function performance
Date: 2009-04-23 08:57:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
W dniu 22 kwietnia 2009 23:47 użytkownik Seref Arikan <
serefarikan(at)kurumsalteknoloji(dot)com> napisał:

> Hi Filip,
> First of all: thanks a lot for your kind response. Here is the create
> script for my schema:
> CREATE TABLE "app"."archetype_data" (
>   "context_id" VARCHAR(1000),
>   "archetype_name" VARCHAR(1000),
>   "archetype_path" VARCHAR(1000),
>   "name" VARCHAR(1000),
>   "value_string" VARCHAR(1000),
>   "value_int" BIGINT,
>   "value_double" DOUBLE PRECISION,
>   "session_id" VARCHAR(1000),
>   "instance_index" INTEGER,
>   CONSTRAINT "archetype_data_pkey" PRIMARY KEY("id")
> Now, regarding your feedback, here are the points, hoping that you can give
> me feedback, and bring me up to speed in the topic, for I've been in the
> upper layers of the software world for so long :)

Yes that's easy to observe; but Java and Postgres can go together, I assure
you :)

> Please forgive me for further questions:

come on, nothing to forgive, if I did not like answering questions I would
not read this at all.

> Are you telling me that due to name resolution process, my use of variable
> and column names for context_id and session_id are causing problems?

that's what I'm telling, doesn't I?

> I'll change variable names into names which would be obviously different
> from column names.

> I used the temp table to speed up the following selects, since the actual
> table has more than 9 million rows. after creating the temp table, I am
> selecting from 50K rows. Am I wrong about the performance gain here? What
> would you suggest instead?

Select once. ONCE. Not to temp table, just to a implicit cursor [like here:]
. You can use ORDER BY session_id , so in ONE pass you will be able to
all needed computations. ( you will have block of records belonging to one
session_id, then another block for next session_id and so on).

Regarding performance: if you create index on (context_id, session_id) this
query will be fast.

> Temp tables forced me to use execute, after hitting a known problem, also
> expressed in the faq, is this what you're talking about?

yes that's it, but as I sad before - you really can get rid of temporary
tables here.

> I will be investing serious time into postgresql from now on, and I hope
> you can give me couple of useful hints, to ease my way forward :) Looking at
> the schema, can you think of a better way to send this result set to a java
> based app?

Better way to query or better schema?

If you mean better way to query - I would just select all rows and combine
them in upper layer. ARRAYs are not so cute for me.

If you mean better schema... That's the hardest question, as other guys
suggested. You will have to decide what to use. I know that some ORM for
Java (Hibernate, namely) produce quite decent database schemas. NOT E-A-V
model. Maybe this will suit you.

good luck!

Filip Rembiałkowski

In response to


pgsql-general by date

Next:From: Karsten HilbertDate: 2009-04-23 09:00:59
Subject: Re: Help request to improve function performance
Previous:From: Seref ArikanDate: 2009-04-23 08:44:53
Subject: Re: Help request to improve function performance

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group