473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Variable in PostgreSQL 7.4.x

Hello,

I am programming web portal. I have table c_language with attributes
i_language_id INT4 PK
c_code CHAR(2) NOT NULL UNIQUE
v_name VARCHAR(32)

and tables referenced to c_language. I need create some variable, which
contain value of i_language_id during one web request.

at start of request I create temporary table f.e.:
SELECT i_language_id INTO lang FROM c_language WHERE c_code='EN';

There is stored procedure get_lang(); which only do
SELECT i_language_id FROM land;

Every view is build like f.e.:
SELECT * FROM TABLE WHERE i_language_id=get_lang();

this create, that on my application layer I need not write language
condition into every query.

but creating of temporary table in every web request is IMHO slow. Is
there another way, how to store temporary variable into postgres.

thanx, hlavki

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
2 1687
On Tue, May 04, 2004 at 16:39:55 +0200,
Michal Hlavac <hl****@medium13.sk> wrote:
Hello,

I am programming web portal. I have table c_language with attributes
i_language_id INT4 PK
c_code CHAR(2) NOT NULL UNIQUE
v_name VARCHAR(32)

and tables referenced to c_language. I need create some variable, which
contain value of i_language_id during one web request.

at start of request I create temporary table f.e.:
SELECT i_language_id INTO lang FROM c_language WHERE c_code='EN';

There is stored procedure get_lang(); which only do
SELECT i_language_id FROM land;

Every view is build like f.e.:
SELECT * FROM TABLE WHERE i_language_id=get_lang();

this create, that on my application layer I need not write language
condition into every query.

but creating of temporary table in every web request is IMHO slow. Is
there another way, how to store temporary variable into postgres.


If the languages you support are a subset of what your postgres installation
supports than you can probably store the language in the lc_messages
without breaking anything. The value can be retrived via a function in
your views. This wouldn't leave behind tuples to be vacuumed. So if it
will work in your situation, I think it is probably the best. (In 7.5
there is some sort of custom GUC feature that you might be able to
use in a similar fashion.)

Otherwise you can created a table that has either backend pids or the
value of a sequence as the key and the appropiate language for this session
as a second column. You can use pg_backend_pid() or currval('your_seq_name')
in views. If you do things this way you are going to need to vacuum this
table very frequently. You may or may not want an index on the table.
If you can keep up with vacuuming, you are probably better off without
an index.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #2
On Tue, May 04, 2004 at 16:39:55 +0200,
Michal Hlavac <hl****@medium13.sk> wrote:
Hello,

I am programming web portal. I have table c_language with attributes
i_language_id INT4 PK
c_code CHAR(2) NOT NULL UNIQUE
v_name VARCHAR(32)

and tables referenced to c_language. I need create some variable, which
contain value of i_language_id during one web request.

at start of request I create temporary table f.e.:
SELECT i_language_id INTO lang FROM c_language WHERE c_code='EN';

There is stored procedure get_lang(); which only do
SELECT i_language_id FROM land;

Every view is build like f.e.:
SELECT * FROM TABLE WHERE i_language_id=get_lang();

this create, that on my application layer I need not write language
condition into every query.

but creating of temporary table in every web request is IMHO slow. Is
there another way, how to store temporary variable into postgres.


If the languages you support are a subset of what your postgres installation
supports than you can probably store the language in the lc_messages
without breaking anything. The value can be retrived via a function in
your views. This wouldn't leave behind tuples to be vacuumed. So if it
will work in your situation, I think it is probably the best. (In 7.5
there is some sort of custom GUC feature that you might be able to
use in a similar fashion.)

Otherwise you can created a table that has either backend pids or the
value of a sequence as the key and the appropiate language for this session
as a second column. You can use pg_backend_pid() or currval('your_seq_name')
in views. If you do things this way you are going to need to vacuum this
table very frequently. You may or may not want an index on the table.
If you can keep up with vacuuming, you are probably better off without
an index.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Otis Green | last post by:
Vote for or against a new newsgroup proposal. To summarize what you need to do, just send an empty e-mail to postgresql-ballot@netagw.com You will receive a ballot by e-mail. Follow the...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
0
by: Bill J. | last post by:
I have to update a PostgreSQL linked server through MSSQL2K. I first configured the connection with ODBC as follows and I can do queries with no problem: EXEC sp_droplinkedsrvlogin @rmtsrvname...
4
by: Christopher Murtagh | last post by:
Greetings, Thanks to a lot of help on this list, I've managed to get my pl/perl function working. However, I have an unexpected result. Here's a simple way to reproduce this problem: CREATE...
0
by: greg | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is a PGP-signed copy of the checksums for PostgreSQL version 7.4. The latest copy of the checksums for this and other versions, as well...
3
by: joseph speigle | last post by:
hello list, I want to do something like the following: address=# @var = select max(id) from passwd; ERROR: parser: parse error at or near "@" at character 1 address=# var = select max(id)...
1
by: phil campaigne | last post by:
On Mon, 1 Mar 2004, phil campaigne wrote: >> Nigel J. Andrews wrote: >> > > >>> >On Mon, 1 Mar 2004, Phil Campaigne wrote: >>> > >>> >
13
by: Nagib Abi Fadel | last post by:
Is it possible to create a session variable for each user in Postresql ?? Thx
0
by: Shujun Huang | last post by:
Hi, I am working on converting Informix database to Postgre. I have one question for fetching records using PostgreSQL. The record I am fetching is a variable size text string. Before fetching...
0
by: Greg Sabino Mullane | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This is a PGP-signed copy of the checksums for following PostgreSQL versions: 7.4.5 7.4.4 7.3.7
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.