Django orm optimization cheat sheet
Published at March 29, 2019 · 1 min read
django orm 常见的优化措施,除了 count 和 exists 外,select_related prefetch_related 也很常用,其他的则是考虑 queryset 在哪些场景下是 cached 哪些不是,以节省内存及减少数据库查询。 Django orm optimization cheat sheet...
Django orm optimization cheat sheet
Published at March 29, 2019 · 1 min read
django orm 常见的优化措施,除了 count 和 exists 外,select_related prefetch_related 也很常用,其他的则是考虑 queryset 在哪些场景下是 cached 哪些不是,以节省内存及减少数据库查询。 Django orm optimization cheat sheet...
Create a Highly Available PostgreSQL Cluster Using Patroni and HAProxy
Published at March 28, 2019 · 1 min read
通过 patroni 和 haproxy 搭建 PostgreSQL 的高可用集群,主要是 replication Create a Highly Available PostgreSQL Cluster Using Patroni and HAProxy...
Five sharding data models and which is right
Published at March 28, 2019 · 1 min read
五种不同的 sharding 方式,分别是: 1. sharding by customer or tenant, 方便SaaS 及 ERP 2. sharding by geography, 方便多地域的服务。3. sharding by entity id,最常见的一种方式。 4. sharding a graph, 在Facebook Instagram 这种社交网站中较为流行,采用 图数据库。5. time partitioning, 适合于时间序列的数据,常见于各种日志。 Five sharding data models and which is right...
Database sharding explained in plain English
Published at March 28, 2019 · 1 min read
postgresql 集群管理工具 citus 背后 sharding 的技术方案。把 id 均匀的哈希到 -2^32 - 2^32 之间的值,若增加 node 则将原有的 shards 进行移动到新的节点以实现轻松扩容。 Database sharding explained in plain English...
How do you calculate how much hardware resources you need for a database?
Published at March 28, 2019 · 1 min read
如何详细计算一个数据库扩容所需要的硬件资源,内存,CPU,硬盘 How do you calculate how much hardware resources you need for a database?...
3 ways to detect slow queries in PostgreSQL - Cybertec
Published at March 28, 2019 · 1 min read
几种检测 postgresql 慢查询的方法,针对全库,需要开启慢查询的日志打印,另外配合 explain 确认查询的方式,是索引还是顺序查询等。最后一个则是利用 pg_stat_statements 查看查询的数量、时间等状态信息。 3 ways to detect slow queries in PostgreSQL - Cybertec...
Advanced Visualization for Data Scientists with Matplotlib
Published at March 26, 2019 · 1 min read
数据可视化中 matplotlib 的一些高级用法 Advanced Visualization for Data Scientists with Matplotlib...
Django ORM optimization story on selecting the least possible
Published at March 23, 2019 · 1 min read
通过 benchmark 的方式分别测试 only values values_list 几个方法的查询速度 Django ORM optimization story on selecting the least possible...
Save Cash by running Kubernetes services on preemptible VMs in Google Cloud
Published at March 23, 2019 · 1 min read
k8s 使用 gcp 的抢占式实例,在传统实例与抢占式实例同时存在的情况下,将 nodeSelector 改成 nodeAffinity 保证即使没有抢占式实例时也能保证服务的可用性。 Save Cash by running Kubernetes services on preemptible VMs in Google Cloud...
Best practices working with Django models in Python
Published at March 23, 2019 · 1 min read
使用 python model 时的最佳实践 Best practices working with Django models in Python...