Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisted computed by columns [CORE2463] #2876

Open
firebird-automations opened this issue May 14, 2009 · 11 comments
Open

Persisted computed by columns [CORE2463] #2876

firebird-automations opened this issue May 14, 2009 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @cincuranet

Votes: 1

It would be nice to have support for persisted computed by columns. Of course works only for "deterministic" expressions.

@firebird-automations
Copy link
Collaborator Author

Modified by: @cincuranet

Component: Engine [ 10000 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Claudio Valderrama C. (robocop)

What's the difference with a normal field that's populated by a before insert, before update trigger?

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

The ease of usage and maintaining.

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

Jiri,

How would the engine know fi the expression was "deterministic"?

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Jiri, if you were talking about performance, I would understand what is a "persisted computed by column".

But as you talked about "ease of usage and maintaining", I feel I don't know what it is. Could you elaborate?

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

ad deterministic> That's the question for discussion. But taking into account you can create computed index i.e. based on current_timestamp, this can be allowed for persisted computed columns too.

as usage ...>Well, with maintaining I covered in my mind the performace and also the ability to chnge the expression directly where the column is defined without need to change the trigger(s) and looking for these (if it's not one for all).

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

1) FB 2.5 has ALTER ... COMPUTED.

2) What make you think that a persisted (on disk) column will be faster than a computed?

I'm thinking you want to put heavy queries on them. But if queries depends on another table/records, how the engine can figure out to update the persistent column when that table/records changes?

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

1) Yes, that's why I'm saying, you can easily change the expression.

2) If the computation is easy, than the computed will be faster. But if it's really hard, like some "long" mathematical formula etc., then I think, fetching this will be faster than computing it again and again.

ad another table> Yes, that's why I was talking about deterministic expressions.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Ok. IMHO, it looks something that triggers can do nice.

I see MSSQL has it. Do you know, if when expression is altered, in the next time the column is read it will return and persist the new value on the fly? If it does, there is one advantage than trigger. But also, it may be problematic, as it will defeat its purpose of performance and someone will note only when running the query.

@firebird-automations
Copy link
Collaborator Author

Commented by: @cincuranet

In MS SQL the computed columns (both persisted and not persisted) cannot be altered.

> if when expression is altered, in the next time the column is read it will return and persist the new value on the fly?
Yes, that was what I was thinking about. And if you need to regenerate it immediatelly, just read the whole table.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

Don't seams similar for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant