Subject | Re: [ib-support] Re: error when add computed |
---|---|
Author | Lucas Franzen |
Post date | 2003-04-04T17:56:40Z |
Ronaldo,
not.
But I still insist that it's nonsense to do sth. like this.
What do you need it for? To keep track of the number of students that
are in course?
You can achieve this by much better means, i.e. asking for it when you
need it.
So, if you want to have a view of your courses and the number of
students participating you can still ask for this with simple SQL like:
SELECT C.COURSE_NAME, COUNT(*)
FROM COURSES C
JOIN STUDENTS S ON C.CSID = S.CS_ID
GROUP BY C.COURSE_NAME
WHERE ....
which will give you a nice overview.
AND: It will count the (sub-)records just and only when you ask for it.
SELECT COUNT(*) might be okay with Desktop-databases, maybe even with
Oracle or MSSQL, but it should be used rarely (if at all) with IB/FB due
to the multiple generation architecture -
count (*) is not written somewhere in a header of a table - it has to be
evaluated every time you call it and this means that the table has to be
scanned totally (which makes it quite slow).
Luc.
> I agreee with you. It's better put this column in another table.No, it's better NOT to do that at all.
> an error is generated when I try to put this column. I think thatSince I never tried something like this I don't know if it's an error or
> it's not have effect in the insert because, I will not mention this
> column in inserts.
> Look my other case:
>
> alter table COURSE ADD QTD_STUDENTS COMPUTED BY
> (
> SELECT COUNT(*) FROM COURSE_STUDENTS CS
> WHERE CS.ID_COURSE = COURSE.ID_COURSE
> )
>
> I receive the error mencioned below when I try this.
not.
But I still insist that it's nonsense to do sth. like this.
What do you need it for? To keep track of the number of students that
are in course?
You can achieve this by much better means, i.e. asking for it when you
need it.
So, if you want to have a view of your courses and the number of
students participating you can still ask for this with simple SQL like:
SELECT C.COURSE_NAME, COUNT(*)
FROM COURSES C
JOIN STUDENTS S ON C.CSID = S.CS_ID
GROUP BY C.COURSE_NAME
WHERE ....
which will give you a nice overview.
AND: It will count the (sub-)records just and only when you ask for it.
SELECT COUNT(*) might be okay with Desktop-databases, maybe even with
Oracle or MSSQL, but it should be used rarely (if at all) with IB/FB due
to the multiple generation architecture -
count (*) is not written somewhere in a header of a table - it has to be
evaluated every time you call it and this means that the table has to be
scanned totally (which makes it quite slow).
Luc.