Posts

Showing posts with the label postgresql

Everything you need to consider when choosing COSMOSDB API

Image
  Azure CosmosDB is a modern distributed data store that can handle any data volume, any data velocity ( data arrival speed) and any data variety (different types of data). CosmosDb requires minimal setup and management efforts. It is very easy to integrate CosmosDB into your existing data infrastructure using various APIs that can either mimic your existing data management systems, like MongoDB, PostgreSQL or Cassandra and provide you with under 10s latency from anywhere, 99.999% availability and instant scalability. From the cost perspective, storage costs and utilization costs are almost the same regardless of which API you are planning to use. There is neither an autoscale nor serverless option for PostgreSQL API. Serverless NoSql API,  Serverless   Gremlin API,  Serverless  MongoDB API,  Serverless  Cassandra API and Serverless Table API are available as only as Single Region write architecture. If you are interested in Multi-region write clu...

SQL Server Insert Parent and Child Records with One Statement

Image
A few days ago, one of the developers asked me if that was possible to generate test data by performing multiple nested  INSERT statements , each of them involving inserting new rows into several parent tables and  in the same statement  reusing the autogenerated primary keys for the foreign key columns in the child table.  The developer was working with PostgreSql and so I tried to find a solution for both PostgreSql and SQL Server to learn the differences in the ANSI features implementation in these different database systems. Read the solution on my blogpost here:  https://www.mssqltips.com/sqlservertip/6142/sql-server-insert-parent-and-child-records-with-one-statement/ Yours, Maria P.S.  (Picture is taken from Kendra Little website)  
Image
Have you ever wondered how MySQL and PostgreSQL are different? Take a look at the mapping that I have made for myself:  https://www.mssqltips.com/sqlservertip/5745/compare-sql-server-mysql-and-postgresql-features/ I would be happy to see comments posted for this blog and add more things to the mapping. Yours Maria  P.S. The ranking screenshot was taken from db-engines site:  https://db-engines.com/en/ranking/relational+dbms  

How would you do dynamic pivot SQL in Amazon Redshift? (This elegant script might be used in many other databases as well)

Image
Several days ago I have spent a few hours of my life figuring out how to do dynamic pivot in Amazon Redshift. To tell you the truth, I have expected much more from this DBMS SQL language. Redshift is based on Postgre SQL 8.0.2 ( which was released in 2005 !!!! ) Anything you would want for this, not too difficult task,  does not exits.  No stored procedures. No JSON datatype. No variables outside of UDF, no queries inside UDFs. “UDF can be used to calculate values but cannot be used to call SQL functions”. Python UDFs also cannot query the data, only perform calculations. Finally I have found one useful function LISTAGG that helped me to get distinct values of all pivoted columns. For each group in a query, the LISTAGG aggregate function orders the rows for that group according to the ORDER BY expression, then concatenates the values into a single string. LISTAGG( [DISTINCT] aggregate_expression [, 'delimiter' ] )  [ WITHIN GROUP (ORDER BY order_list) ] ...