Database Designer
Can any one explain me how to write frequent queries(format) in .sql file to give database designer? With an example.
1
Can any one explain me how to write frequent queries(format) in .sql file to give database designer? With an example.
Comments
You can query the DC_REQUESTS_ISSUED tables. Something like this:
So the I got at most 100 of the queries executed by all users other than "dbadmin" more than 5 times in the previous week and stuck them in the file "/home/dbadmin/frequent_queries.sql".
Now I can pass this file to DBD!
Thank you jim.
Jim,I need pre join projection of normal table with flex tables.Can it possible?If it is not then what is the alternative solution to get best query performance?.Thanks in advance.
Hi,
If you have a question on a separate topic, can you please create a new post?
Anyway, wow, I've never seen that question asked before
Fyi ... Pre-join projections have been deprecated in Vertica 8.0.
See:
https://my.vertica.com/docs/9.0.x/HTML/index.htm#Authoring/NewFeatures/_VersionIndependent/DeprecatedandRetiredFunctionality.htm
Although as of Vertica 9.0 you can still create pre-join projections, those that involve a FLEX table are not supported...
Example:
Note that final statement: "Unsupported access to flex table: No PREJOIN PROJECTION support"
Thank you jim. But I need that type of requirement.Is there any way alternative to get better query performance of normal table with flex table?
The only way that I can think of to get better performance out of a FLEX table is to materialize them:
See:
https://my.vertica.com/docs/9.0.x/HTML/index.htm#Authoring/FlexTables/MaterializingFlexTables.htm
Refer to the Note:
Materializing virtual columns by promoting them to real columns can significantly improve query performance. Vertica recommends that you materialize important virtual columns before running large and complex queries. Promoted columns cause a small decrease in load performance.
Thank you jim.
If you're on a recent version of Vertica, try out flattened tables, our replacement for prejoins.
https://my.vertica.com/docs/8.1.x/HTML/index.htm#Authoring/AnalyzingData/FlattenedTables/FlattenedTableCreate.htm?TocPath=Analyzing%20Data|Flattened%20Tables|_____2
An example:
create flex table bar();
create table foo (a int, b int default (select whatever::!int from bar where bar.b = foo.a));
Hi Jim, should we have only request_type query or even load is useful?
Hello, Ben! I'm having a similar problem here. I have a fact table with millions of registers with some dimensions. And I need to improve a performance of a query, initially I was trying to create a projection and end up with the error "Prejoin projection is deprecated", then I looked up more information about flattened tables that you suggested as a solution.
However, I have some doubts about this:
1- I was planning on creating a flattened table that used the fact table and the dimensions, but do not alter them, and them be able to create other flattened tables to aggregate data from fact and dimension tables.
2- Is there a way to create a flattened table totally based on the query I was using to create a projection? I was expecting something like create table fact_wide set using [query], is there a way to do it?
3- I only found 2 suggestions of use of flattened tables, creating a table based on other (like: CREATE TABLE fact_wide as select a, b,c from fact; and later add dimension columns one by one with a query related), or altering the fact table adding the dimension columns. Then I come to questions, if I create a flattened table like fact_wide, how the fact data can be refreshed on fact_wide?
4- Also if I alter the fact table (which I'm not sure is a good practice), do I really have to add a query column by column even if its the same dimension table (in my case there are a lot of columns in each dimension)
I created another discussion to talk focused on "Prejoin Project is deprecated", flattened tables or other solutions for this deprecated item:
https://forum.vertica.com/discussion/239997/prejoin-projection-is-deprecated-flattened-tables/p1?new=1
i have a doubt when i am using
SELECT time,user_name,transaction_id,request_type,request FROM dc_requests_issued
where request_type='QUERY'
order by time asc
it is giving me the list of queries that i have fired not by all the users
@AkshayBarakoti - Data Collector table data is stored in flat files in the DataCollector directory on each node. Each node stores its own data and each node has a policy (typically based on size) that determines how long the data is retained. If users are connecting to different nodes there is a potential that the data on each node might not go as far back in history as one another. Especially if most users connect to one node. The query history on that node would roll off more quickly than the other nodes giving the appearance that older queries for those users are not being retained
Quick example:
I have 3 nodes:
Set the disk space retention policy for the Data Collector component RequestsIssued (the DC_REQUESTS_ISSUED table) to 2K and clear:
Now run a query on node 1 as user JIM and JANE, and 1 query on node 2 as user JANE:
I have short SQL statement in a file that shows the disk usage for the Data Collector table, including the users JIM and JANE to show they still have query info stored:
Now I will run the disk usage query several times on node one until the disk usage exceeds 2K:
See, I “lost” history for user JIM but not user JANE…
A Possible Solution:
To maintain a history for some period of time (i.e. 6 days), then set a time capacity for the RequestsIssued data Collector tables on all nodes:
For more info, checkout:
https://www.vertica.com/docs/9.2.x/HTML/Content/Authoring/SQLReferenceManual/Functions/VerticaFunctions/DataCollection/SET_DATA_COLLECTOR_TIME_POLICY.htm
https://forum.vertica.com/discussion/240231/keep-data-collector-information-for-a-set-interval
@AkshayBarakoti - One more thing... Are you running the query as the DBADMIN user?
Non admin users only see their own data in the system tables by default:
@Jim_Knicely thanks man really help actually i was running the query with my user but when i switched to dbadmin it works
one more thing i am from sql server (Microsoft Transact SQL ) background and facing issues with vertica concepts and syntax.it would be a great help if you give me some quick links to learn vertica from scratch