Lateral is the “for each” loop of SQL
.. Lateral is great for Top-N subqueries
.. In PostgreSQL “With” view are more like materialized views
With deleted_rows AS (
Delete from source_tbl
Returning *
)
Insert into destination_tbl
Select * from deleted_rows;
Trying JSON in Django and PostgreSQL (and compare with MongoDB)
class Product(models.Model): name = models.CharField(max_length=100) category = models.ForeignKey(Category) price = models.IntegerField() attributes = JSONField() def __str__(self): return self.name
Product.objects.create(name='Bamboo tshirt', category=tshirt, price=120, attributes={ 'colors': ['white', 'yellow'], 'sizes': ['M', 'L', 'XL'], 'model': 'poet', 'material': 'bamboo', })
Postgres.app
The easiest way to get started with PostgreSQL on the Mac
Adrian: Why I left Heroku, and notes on my new AWS setup
On Friday, we migrated Soundslice from Heroku to direct use of Amazon Web Services (AWS). I’m very, very happy with this change and want to spread the word about how we did it and why you should consider it if you’re in a similar position.