Vertica Blog

Vertica Blog

DBadmin

Business card that says Expert Tips,

Create a Python UDx to Order a List of Values

User-Defined Extensions (UDxs) are functions contained in external shared libraries that are developed in C++, Python, Java, or R using the Vertica SDK. The external libraries are defined in the Vertica catalog using the CREATE LIBRARY statement. They are best suited for analytic operations that are difficult to perform in SQL, or need to be...
Hand writing the text: Helpful Tips

Forcing a Merge Join

The Vertica optimizer implements a join with one of the following algorithms: Merge join is used when projections of the joined tables are sorted on the join columns. Merge joins are faster and use less memory than hash joins. Hash join is used when projections of the joined tables are not already sorted on the...
Quick Tip - blue button

Displaying the Vertica Code Name

Every major release of Vertica has a code name. To find out the Vertica code name of your database, you can query the DC_STARTUPS Data Collector table. Example: Helpful Link: Have fun!
Vintage businessman concept pointing on the wall wearing futuristic helmet at office

Descending Sequences

The default increment for a Vertica sequence is 1. But you can also create a sequence that has a negative increment so that you can have a count down. Example: Helpful Links: Have fun!
Helpful Tips message on post-it note

Display Session Sequence Cached Values Remaining

To optimize the performance of large INSERT SELECT and COPY operations, Vertica uses sequence caching. To allocate cache among the nodes in a cluster for a given sequence, Vertica uses the following process: By default, when a session begins, the cluster initiator node requests cache for itself and other nodes in the cluster. The initiator...
Calendar February 29 for Leap Year

Is This a Leap Year?

A Common Year in the Gregorian calendar has 365 days. A Leap Year, which has 366 days, occurs nearly every 4 years. One algorithm to determine if a year is a Common or a Leap Year is: I’d like to create a user-defined SQL function in Vertica that will let me know if the year...
Cupcakes with blue icing and lit birthday candles

How Old Am I (In Months)?

You are probably aware that Vertica has a built-in function named AGE_IN_YEARS. It returns the difference in years between two dates, expressed as an integer. Example: My son is turning 18 this year! I was curious to know how many months he’s been on the planet, so I figured that I could just multiply his...

Display the Vertica Process Memory Allocated

For common Vertica cluster configurations, there should be a single running Vertica process on each node. You can use the Linux ps command to determine the process ID of the Vertica process. Once you have the process ID, you can display the amount of memory that has been allocated to the Vertica process using the...

Display Database Statement Counts by Type

There are many types of statements that can be executed in Vertica. Examples include queries, DDL (Data Definition Language), and utility statements. To summarize all the types of statements being executed, you can query the QUERY_PROFILES system table. Example: I’d like to view a count of each statement type across my cluster since the first...
Hand writing the text: Helpful Tips

Use Time Series Analytics to Generate a List of Dates at a Specific Start Date

Time series analytics evaluate the values of a given set of variables over time and group those values into a window (based on a time interval) for analysis and aggregation. This feature comes in handy if I need to generate a list of dates using some interval, for example 1 MONTH. Example: But why did...

Truncating a Timestamp

The built-in Vertica function DATE_TRUNC truncates date and time values to the specified precision. The return value is the same data type as the input value. All fields that are less than the specified precision are set to 0, or to 1 for day and month. Example: So did the current Millennium begin on January...

Partition a Table By More Than One Column

The Vertica partitioning capability divides one large table into smaller pieces based on values in one or more columns. Partitions can make data lifecycle management easier and improve the performance of queries whose predicate is included in the partition expression. To partition a table by more than one column, use the HASH function! Example: Helpful...