开发者

View vs ODBC query

I am designing a database in PostgreSQL on a dedicated server. I want certain complex queries to be run often, and the results to be accessible with ODBC/JDBC clients such as MS-Access or reporting softwar开发者_运维百科e.

As I see it, I have the option to either define a VIEW within PostgreSQL and import it using ODBC, or to define the query within the ODBC client and import the underlying tables.

Which is best? Are there any other options that I am missing?


I'm not sure what you mean by "import". A view is essentially a predefined query which you can select data from as you would from a table. When you execute a SELECT query, whether you're accessing the data tables directly or through a view, only the results of the query are sent back to you.

If you have to execute the same query from various different clients it might be a good idea to define a view for that query.

Share and enjoy.


You say you have complex queries that create an output that you want to be used for reporting purposes.

Rollups, aggregations, etc are performed and stored in the data warehouse in pretty much the same way as you describe.

If this is what you want, you should consider having a table that stores the output of the query. Use a scheduling program to run your ComplexQuery at appropriate times and store the output in a table.

You have to decide why you want this. The complexity of the query is not a factor as much as the amount of resources that required database server to run the query. If this is small enough and it does not negatively affect performance, and you need your data real time, use a View. If you can live with periodically refreshed data, that is quickly available and does not put a high load on the server, go for an aggregate table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜