Unix Technical Forum

Indexed Views

This is a discussion on Indexed Views within the pgsql Novice forums, part of the PostgreSQL category; --> Does postgreSQL have the ability to index a view? Or index a computed column such as an aggregate? Thanks...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:35 PM
Ketema Harris
 
Posts: n/a
Default Indexed Views

Does postgreSQL have the ability to index a view? Or index a computed
column such as an aggregate?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:35 PM
Sean Davis
 
Posts: n/a
Default Re: Indexed Views

You simply index the underlying table.

Sean



On 2/15/06 10:35 AM, "Ketema Harris" <ketema@gmail.com> wrote:

> Does postgreSQL have the ability to index a view? Or index a computed

column
> such as an aggregate?


Thanks




---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:35 PM
Srinivas Iyyer
 
Posts: n/a
Default A function to count number of terms - something wrong please help

Dear group,
I wrote a function to return the number of records
that has this query term associated with.

Something is going wrong. Looking forward some help to
correct this function.
Could some one help if this function is correct way,
or please suggest other way please.

Thanks
srini

SQL query and result:
test=# select distinct seq_name from sequence, go_seq,
gos where gos.go_term = 'protein binding' AND
gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
sequence.seq_id ;
seq_name
---------------
A2M
AATF
ABCD1
ABCD2
ABCD3
........
........
ZP3
ZRANB1
ZW10
ZYX
(3862 rows)

================================================== =
Function:
CREATE FUNCTION fetch_count_fterm(term) RETURNS char
AS '
DECLARE
referrer_keys1 RECORD;
fterm ALIAS FOR $1;
mcounts integer;
BEGIN
referrer_keys1 IN SELECT distinct seq_name
from sequence,go_seq,gos where gos.go_term = fterm AND
gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
sequence.seq_id
mcounts := select count(*) from referrer_keys1
return mcounts;
END;
' LANGUAGE plpgsql;

test=# \i fetch_Fterm.sql
psql:fetch_Fterm.sql:11: ERROR: type term does not
exist
test=#



Could some one help if this function is correct way,
or please suggest other way please.

Thanks



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 10:35 PM
Sean Davis
 
Posts: n/a
Default Re: A function to count number of terms - something




On 2/15/06 12:41 PM, "Srinivas Iyyer" <srini_iyyer_bio@yahoo.com> wrote:

> Dear group,
> I wrote a function to return the number of records
> that has this query term associated with.
>
> Something is going wrong. Looking forward some help to
> correct this function.
> Could some one help if this function is correct way,
> or please suggest other way please.
>
> Thanks
> srini
>
> SQL query and result:
> test=# select distinct seq_name from sequence, go_seq,
> gos where gos.go_term = 'protein binding' AND
> gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
> sequence.seq_id ;
> seq_name
> ---------------
> A2M
> AATF
> ABCD1
> ABCD2
> ABCD3
> .......
> .......
> ZP3
> ZRANB1
> ZW10
> ZYX
> (3862 rows)
>
> ================================================== =
> Function:
> CREATE FUNCTION fetch_count_fterm(term) RETURNS char

^^^^

Should be a data type (like "TEXT").
> AS '
> DECLARE
> referrer_keys1 RECORD;
> fterm ALIAS FOR $1;
> mcounts integer;
> BEGIN
> referrer_keys1 IN SELECT distinct seq_name
> from sequence,go_seq,gos where gos.go_term = fterm AND
> gos.gos_id = go_seq.gos_id AND go_seq.seq_id =
> sequence.seq_id
> mcounts := select count(*) from referrer_keys1
> return mcounts;
> END;
> ' LANGUAGE plpgsql;
>
> test=# \i fetch_Fterm.sql
> psql:fetch_Fterm.sql:11: ERROR: type term does not
> exist
> test=#
>
>
>
> Could some one help if this function is correct way,
> or please suggest other way please.
>
> Thanks
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match




---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:51 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com