Обсуждение: do queries from strings in pgplsql

Поиск
Список
Период
Сортировка

do queries from strings in pgplsql

От
Virgilio Sanz
Дата:
Hi list,

I'm just added to the list and I'm not sure whether the following is a
FAQ or not possible. Anyway, here it goes:
       Is it possible to execute a query stored into a string?

I mean, something like:

function test(text) as returns opaque as '
declare v_weekday alias for $1; s_qry text; rec record;
begin s_qry = ''select field1,field2, '' || v_weekday || '' from t_diary''; for rec in exec_sql(s_qry)loop
--                 ^ that is what I'm looking for...
--        [do what is needed] end loop;
end;
' language 'plpgsql';

Thanks in advance,
Virgilio Sanz

--
Virgilio Sanz               vsanz@el-mundo.net virgilio.sanz@el-mundo.es
Diario el Mundo en Internet http://www.el-mundo.es
Email me with "send key pub" on subject to get my public key
"Success covers a multitude of blunders."
-- George Bernard Shaw

Except operation

От
Satyajeet Seth
Дата:
Hi
The query: 
select * from webdata except select * from webdata1;takes abysmally long .How can I optimise it?
The particulars are:

tracedb=> \d webdata
Table    = webdata
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| tid                              | int4                             |
4 |
| itemid                           | int4                             |
4 |
| ordering                         | int4                             |
4 |
+----------------------------------+----------------------------------+-------+

tracedb=> \d webdata1
Table    = webdata1
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| tid                              | int4                             |
4 |
| itemid                           | int4                             |
4 |
| ordering                         | int4                             |
4 |
+----------------------------------+----------------------------------+-------+
tracedb=> select count(*) from webdata;
count
-----
91155
(1 row)

tracedb=> select count(*) from webdata1;
count
-----9550
(1 row)

Regards
Satya