Thread: index on an int8 column

index on an int8 column

From
Sarah Officer
Date:
I have a table with a column of type int8.  When I try to create an
index on it, the
database protests and gives the following error message:

    ERROR:  Can't find a default operator class for type 20.

Is there an easy fix for this?  I assumed builtin numeric types would
have
default comparison functions.

Also, if I am not posting to the appropriate mailing list, please let me
know.

Thanks in advance,

Sarah Officer
officers@aries.tucson.saic.com



Re: [GENERAL] index on an int8 column

From
José Soares
Date:
It works on 6.5beta1.

Sarah Officer ha scritto:

> I have a table with a column of type int8.  When I try to create an
> index on it, the
> database protests and gives the following error message:
>
>     ERROR:  Can't find a default operator class for type 20.
>
> Is there an easy fix for this?  I assumed builtin numeric types would
> have
> default comparison functions.
>
> Also, if I am not posting to the appropriate mailing list, please let me
> know.
>
> Thanks in advance,
>
> Sarah Officer
> officers@aries.tucson.saic.com

______________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'



Row Count?

From
Bruce Tong
Date:
This is probably one of those things everyone knows except me, but my
search of the documentation only turned up it's not a keyword in
PostgreSQL...

SELECT * FROM foo WHERE ROW_COUNT < 10;

Is there anything like "ROW_COUNT" or "ROWCOUNT" in PostgreSQL?

I've been looking through "The Practical SQL Handbook" as I know it is a
significant influence on PostgreSQL, and I haven't found anything similar
there either.


Bruce Tong                 |  Got me an office; I'm there late at night.
Systems Programmer         |  Just send me e-mail, maybe I'll write.
Electronic Vision / FITNE  |
zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century



Re: [GENERAL] Row Count?

From
Thomas Reinke
Date:
Try
   "select count(*) from row"

to get a count of the number of rows.

If trying to receive 10 rows, try

begin;
declare thomas cursor for select * from foo;
fetch 10 in thomas;
end;

Bruce Tong wrote:
>
> This is probably one of those things everyone knows except me, but my
> search of the documentation only turned up it's not a keyword in
> PostgreSQL...
>
> SELECT * FROM foo WHERE ROW_COUNT < 10;
>
> Is there anything like "ROW_COUNT" or "ROWCOUNT" in PostgreSQL?
>
> I've been looking through "The Practical SQL Handbook" as I know it is a
> significant influence on PostgreSQL, and I haven't found anything similar
> there either.
>
> Bruce Tong                 |  Got me an office; I'm there late at night.
> Systems Programmer         |  Just send me e-mail, maybe I'll write.
> Electronic Vision / FITNE  |
> zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century

--
------------------------------------------------------------
Thomas Reinke                            Tel: (416) 460-7021
Director of Technology                   Fax: (416) 598-2319
E-Soft Inc.                         http://www.e-softinc.com

Re: [GENERAL] Row Count?

From
Bruce Tong
Date:
> > SELECT * FROM foo WHERE ROW_COUNT < 10;
> > Is there anything like "ROW_COUNT" or "ROWCOUNT" in PostgreSQL?

> If trying to receive 10 rows, try
>
> begin;
> declare thomas cursor for select * from foo;
> fetch 10 in thomas;
> end;

Ooo, a cursor. I'll have to look into those. I was thinking I could just
issue "select * from foo" and then only use the first 10 results, but that
seemed like such a waste of time since there's likely to be 100's of
records. Admittedly I'm ignorant of the solution you pose and I'll have to
do some research, but it seems it too might also have the postmaster
return all of the records, of which I would only use 10. Am I wrong?


Bruce Tong                 |  Got me an office; I'm there late at night.
Systems Programmer         |  Just send me e-mail, maybe I'll write.
Electronic Vision / FITNE  |
zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century



Re: [GENERAL] Row Count?

From
Thomas Reinke
Date:

Bruce Tong wrote:
>
> > > SELECT * FROM foo WHERE ROW_COUNT < 10;
> > > Is there anything like "ROW_COUNT" or "ROWCOUNT" in PostgreSQL?
>
> > If trying to receive 10 rows, try
> >
> > begin;
> > declare thomas cursor for select * from foo;
> > fetch 10 in thomas;
> > end;
>
> Ooo, a cursor. I'll have to look into those. I was thinking I could just
> issue "select * from foo" and then only use the first 10 results, but that
> seemed like such a waste of time since there's likely to be 100's of
> records. Admittedly I'm ignorant of the solution you pose and I'll have to
> do some research, but it seems it too might also have the postmaster
> return all of the records, of which I would only use 10. Am I wrong?

Yes. It is designed explicitly for the purpose of limiting the returns.
For example, if you have a database of several million records and
want only 10 to be returned...

For example, a piece of code that wanted to be conservative on memory
usage, while handling millions of records in the database, might issue
(pseudo-code):

begin;
   declare thomas cursor for select * from foo;
   do
     res = fetch 10 in thomas;
     iRows = nTuples(res)
     process_records;
   while(iRows>0);
end;

From a coding perspective, you deal with the results of the fetch just
as if they had come from the select.

Hope this helps

Thomas
>
> Bruce Tong                 |  Got me an office; I'm there late at night.
> Systems Programmer         |  Just send me e-mail, maybe I'll write.
> Electronic Vision / FITNE  |
> zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century

--
------------------------------------------------------------
Thomas Reinke                            Tel: (416) 460-7021
Director of Technology                   Fax: (416) 598-2319
E-Soft Inc.                         http://www.e-softinc.com

Re: [GENERAL] Row Count?

From
Dustin Sallings
Date:
On Wed, 5 May 1999, Bruce Tong wrote:

    Someone has a table with a column named row_count.

# This is probably one of those things everyone knows except me, but my
# search of the documentation only turned up it's not a keyword in
# PostgreSQL...
#
# SELECT * FROM foo WHERE ROW_COUNT < 10;
#
# Is there anything like "ROW_COUNT" or "ROWCOUNT" in PostgreSQL?
#
# I've been looking through "The Practical SQL Handbook" as I know it is a
# significant influence on PostgreSQL, and I haven't found anything similar
# there either.
#
#
# Bruce Tong                 |  Got me an office; I'm there late at night.
# Systems Programmer         |  Just send me e-mail, maybe I'll write.
# Electronic Vision / FITNE  |
# zztong@laxmi.ev.net        |  -- Joe Walsh for the 21st Century
#
#
#
#

--
SA, beyond.com           My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________