TigerData logo
TigerData logo
  • Product

    Tiger Cloud

    Robust elastic cloud platform for startups and enterprises

    Agentic Postgres

    Postgres for Agents

    TimescaleDB

    Postgres for time-series, real-time analytics and events

  • Docs
  • Pricing

    Pricing

    Enterprise Tier

  • Developer Hub

    Changelog

    Benchmarks

    Blog

    Community

    Customer Stories

    Events

    Support

    Integrations

    Launch Hub

  • Company

    Contact us

    About

    Timescale

    Partners

    Security

    Careers

Log InTry for free
Home
AWS Time-Series Database: Understanding Your OptionsStationary Time-Series AnalysisThe Best Time-Series Databases ComparedTime-Series Analysis and Forecasting With Python Alternatives to TimescaleWhat Are Open-Source Time-Series Databases—Understanding Your OptionsWhy Consider Using PostgreSQL for Time-Series Data?Time-Series Analysis in RWhat Is Temporal Data?What Is a Time Series and How Is It Used?Is Your Data Time Series? Data Types Supported by PostgreSQL and TimescaleUnderstanding Database Workloads: Variable, Bursty, and Uniform PatternsHow to Work With Time Series in Python?Tools for Working With Time-Series Analysis in PythonGuide to Time-Series Analysis in PythonUnderstanding Autoregressive Time-Series ModelingCreating a Fast Time-Series Graph With Postgres Materialized Views
Understanding PostgreSQLOptimizing Your Database: A Deep Dive into PostgreSQL Data TypesUnderstanding FROM in PostgreSQL (With Examples)How to Address ‘Error: Could Not Resize Shared Memory Segment’ How to Install PostgreSQL on MacOSUnderstanding FILTER in PostgreSQL (With Examples)Understanding GROUP BY in PostgreSQL (With Examples)PostgreSQL Join Type TheoryA Guide to PostgreSQL ViewsStructured vs. Semi-Structured vs. Unstructured Data in PostgreSQLUnderstanding Foreign Keys in PostgreSQLUnderstanding PostgreSQL User-Defined FunctionsUnderstanding PostgreSQL's COALESCE FunctionUnderstanding SQL Aggregate FunctionsUsing PostgreSQL UPDATE With JOINHow to Install PostgreSQL on Linux5 Common Connection Errors in PostgreSQL and How to Solve ThemUnderstanding HAVING in PostgreSQL (With Examples)How to Fix No Partition of Relation Found for Row in Postgres DatabasesHow to Fix Transaction ID Wraparound ExhaustionUnderstanding LIMIT in PostgreSQL (With Examples)Understanding PostgreSQL FunctionsUnderstanding ORDER BY in PostgreSQL (With Examples)Understanding WINDOW in PostgreSQL (With Examples)Understanding PostgreSQL WITHIN GROUPPostgreSQL Mathematical Functions: Enhancing Coding EfficiencyUnderstanding DISTINCT in PostgreSQL (With Examples)Using PostgreSQL String Functions for Improved Data AnalysisData Processing With PostgreSQL Window FunctionsPostgreSQL Joins : A SummaryUnderstanding OFFSET in PostgreSQL (With Examples)Understanding PostgreSQL Date and Time FunctionsWhat Is Data Compression and How Does It Work?What Is Data Transformation, and Why Is It Important?Understanding the Postgres string_agg FunctionWhat Is a PostgreSQL Left Join? And a Right Join?Understanding PostgreSQL SELECTSelf-Hosted or Cloud Database? A Countryside Reflection on Infrastructure ChoicesUnderstanding ACID Compliance Understanding percentile_cont() and percentile_disc() in PostgreSQLUnderstanding PostgreSQL Conditional FunctionsUnderstanding PostgreSQL Array FunctionsWhat Characters Are Allowed in PostgreSQL Strings?Understanding WHERE in PostgreSQL (With Examples)What Is a PostgreSQL Full Outer Join?What Is a PostgreSQL Cross Join?What Is a PostgreSQL Inner Join?Data Partitioning: What It Is and Why It MattersStrategies for Improving Postgres JOIN PerformanceUnderstanding the Postgres extract() FunctionUnderstanding the rank() and dense_rank() Functions in PostgreSQL
Guide to PostgreSQL PerformanceHow to Reduce Bloat in Large PostgreSQL TablesDesigning Your Database Schema: Wide vs. Narrow Postgres TablesBest Practices for Time-Series Data Modeling: Single or Multiple Partitioned Table(s) a.k.a. Hypertables Best Practices for (Time-)Series Metadata Tables A Guide to Data Analysis on PostgreSQLA Guide to Scaling PostgreSQLGuide to PostgreSQL SecurityHandling Large Objects in PostgresHow to Query JSON Metadata in PostgreSQLHow to Query JSONB in PostgreSQLHow to Use PostgreSQL for Data TransformationOptimizing Array Queries With GIN Indexes in PostgreSQLPg_partman vs. Hypertables for Postgres PartitioningPostgreSQL Performance Tuning: Designing and Implementing Your Database SchemaPostgreSQL Performance Tuning: Key ParametersPostgreSQL Performance Tuning: Optimizing Database IndexesDetermining the Optimal Postgres Partition SizeNavigating Growing PostgreSQL Tables With Partitioning (and More)Top PostgreSQL Drivers for PythonWhen to Consider Postgres PartitioningGuide to PostgreSQL Database OperationsUnderstanding PostgreSQL TablespacesWhat Is Audit Logging and How to Enable It in PostgreSQLGuide to Postgres Data ManagementHow to Index JSONB Columns in PostgreSQLHow to Monitor and Optimize PostgreSQL Index PerformanceSQL/JSON Data Model and JSON in SQL: A PostgreSQL PerspectiveA Guide to pg_restore (and pg_restore Example)PostgreSQL Performance Tuning: How to Size Your DatabaseAn Intro to Data Modeling on PostgreSQLExplaining PostgreSQL EXPLAINWhat Is a PostgreSQL Temporary View?A PostgreSQL Database Replication GuideHow to Compute Standard Deviation With PostgreSQLHow PostgreSQL Data Aggregation WorksBuilding a Scalable DatabaseRecursive Query in SQL: What It Is, and How to Write OneGuide to PostgreSQL Database DesignHow to Use Psycopg2: The PostgreSQL Adapter for Python
Best Practices for Scaling PostgreSQLHow to Design Your PostgreSQL Database: Two Schema ExamplesHow to Handle High-Cardinality Data in PostgreSQLHow to Store Video in PostgreSQL Using BYTEABest Practices for PostgreSQL Database OperationsHow to Manage Your Data With Data Retention PoliciesBest Practices for PostgreSQL AggregationBest Practices for Postgres Database ReplicationHow to Use a Common Table Expression (CTE) in SQLBest Practices for Postgres Data ManagementBest Practices for Postgres PerformanceBest Practices for Postgres SecurityBest Practices for PostgreSQL Data AnalysisTesting Postgres Ingest: INSERT vs. Batch INSERT vs. COPYHow to Use PostgreSQL for Data Normalization
PostgreSQL Extensions: amcheckPostgreSQL Extensions: Unlocking Multidimensional Points With Cube PostgreSQL Extensions: hstorePostgreSQL Extensions: ltreePostgreSQL Extensions: Secure Your Time-Series Data With pgcryptoPostgreSQL Extensions: pg_prewarmPostgreSQL Extensions: pgRoutingPostgreSQL Extensions: pg_stat_statementsPostgreSQL Extensions: Install pg_trgm for Data MatchingPostgreSQL Extensions: Turning PostgreSQL Into a Vector Database With pgvectorPostgreSQL Extensions: Database Testing With pgTAPPostgreSQL Extensions: PL/pgSQLPostgreSQL Extensions: Using PostGIS and Timescale for Advanced Geospatial InsightsPostgreSQL Extensions: Intro to uuid-ossp
Columnar Databases vs. Row-Oriented Databases: Which to Choose?Data Analytics vs. Real-Time Analytics: How to Pick Your Database (and Why It Should Be PostgreSQL)How to Choose a Real-Time Analytics DatabaseUnderstanding OLTPOLAP Workloads on PostgreSQL: A GuideHow to Choose an OLAP DatabasePostgreSQL as a Real-Time Analytics DatabaseWhat Is the Best Database for Real-Time AnalyticsHow to Build an IoT Pipeline for Real-Time Analytics in PostgreSQL
When Should You Use Full-Text Search vs. Vector Search?HNSW vs. DiskANNA Brief History of AI: How Did We Get Here, and What's Next?A Beginner’s Guide to Vector EmbeddingsPostgreSQL as a Vector Database: A Pgvector TutorialUsing Pgvector With PythonHow to Choose a Vector DatabaseVector Databases Are the Wrong AbstractionUnderstanding DiskANNA Guide to Cosine SimilarityStreaming DiskANN: How We Made PostgreSQL as Fast as Pinecone for Vector DataImplementing Cosine Similarity in PythonVector Database Basics: HNSWVector Database Options for AWSVector Store vs. Vector Database: Understanding the ConnectionPgvector vs. Pinecone: Vector Database Performance and Cost ComparisonHow to Build LLM Applications With Pgvector Vector Store in LangChainHow to Implement RAG With Amazon Bedrock and LangChainRetrieval-Augmented Generation With Claude Sonnet 3.5 and PgvectorRAG Is More Than Just Vector SearchPostgreSQL Hybrid Search Using Pgvector and CohereImplementing Filtered Semantic Search Using Pgvector and JavaScriptRefining Vector Search Queries With Time Filters in Pgvector: A TutorialUnderstanding Semantic SearchWhat Is Vector Search? Vector Search vs Semantic SearchText-to-SQL: A Developer’s Zero-to-Hero GuideNearest Neighbor Indexes: What Are IVFFlat Indexes in Pgvector and How Do They WorkBuilding an AI Image Gallery With OpenAI CLIP, Claude Sonnet 3.5, and Pgvector
Understanding IoT (Internet of Things)A Beginner’s Guide to IIoT and Industry 4.0Storing IoT Data: 8 Reasons Why You Should Use PostgreSQLMoving Past Legacy Systems: Data Historian vs. Time-Series DatabaseWhy You Should Use PostgreSQL for Industrial IoT DataHow to Choose an IoT DatabaseHow to Simulate a Basic IoT Sensor Dataset on PostgreSQLFrom Ingest to Insights in Milliseconds: Everactive's Tech Transformation With TimescaleHow Ndustrial Is Providing Fast Real-Time Queries and Safely Storing Client Data With 97 % CompressionHow Hopthru Powers Real-Time Transit Analytics From a 1 TB Table Migrating a Low-Code IoT Platform Storing 20M Records/DayHow United Manufacturing Hub Is Introducing Open Source to ManufacturingBuilding IoT Pipelines for Faster Analytics With IoT CoreVisualizing IoT Data at Scale With Hopara and TimescaleDB
What Is ClickHouse and How Does It Compare to PostgreSQL and TimescaleDB for Time Series?Timescale vs. Amazon RDS PostgreSQL: Up to 350x Faster Queries, 44 % Faster Ingest, 95 % Storage Savings for Time-Series DataWhat We Learned From Benchmarking Amazon Aurora PostgreSQL ServerlessTimescaleDB vs. Amazon Timestream: 6,000x Higher Inserts, 5-175x Faster Queries, 150-220x CheaperHow to Store Time-Series Data in MongoDB and Why That’s a Bad IdeaPostgreSQL + TimescaleDB: 1,000x Faster Queries, 90 % Data Compression, and Much MoreEye or the Tiger: Benchmarking Cassandra vs. TimescaleDB for Time-Series Data
Alternatives to RDSWhy Is RDS so Expensive? Understanding RDS Pricing and CostsEstimating RDS CostsHow to Migrate From AWS RDS for PostgreSQL to TimescaleAmazon Aurora vs. RDS: Understanding the Difference
5 InfluxDB Alternatives for Your Time-Series Data8 Reasons to Choose Timescale as Your InfluxDB Alternative InfluxQL, Flux, and SQL: Which Query Language Is Best? (With Cheatsheet)What InfluxDB Got WrongTimescaleDB vs. InfluxDB: Purpose Built Differently for Time-Series Data
5 Ways to Monitor Your PostgreSQL DatabaseHow to Migrate Your Data to Timescale (3 Ways)Postgres TOAST vs. Timescale CompressionBuilding Python Apps With PostgreSQL: A Developer's GuideData Visualization in PostgreSQL With Apache SupersetMore Time-Series Data Analysis, Fewer Lines of Code: Meet HyperfunctionsIs Postgres Partitioning Really That Hard? An Introduction To HypertablesPostgreSQL Materialized Views and Where to Find ThemTimescale Tips: Testing Your Chunk Size
Postgres cheat sheet
HomeTime series basicsPostgres basicsPostgres guidesPostgres best practicesPostgres extensionsPostgres for real-time analytics
Sections

Postgres overview

Understanding PostgreSQLOptimizing Your Database: A Deep Dive into PostgreSQL Data Types

Postgres errors

How to Address ‘Error: Could Not Resize Shared Memory Segment’ 5 Common Connection Errors in PostgreSQL and How to Solve ThemHow to Fix No Partition of Relation Found for Row in Postgres DatabasesHow to Fix Transaction ID Wraparound Exhaustion

Install postgres

How to Install PostgreSQL on LinuxHow to Install PostgreSQL on MacOS

Postgres clauses

Understanding FROM in PostgreSQL (With Examples)Understanding FILTER in PostgreSQL (With Examples)Understanding HAVING in PostgreSQL (With Examples)Understanding GROUP BY in PostgreSQL (With Examples)Understanding LIMIT in PostgreSQL (With Examples)Understanding ORDER BY in PostgreSQL (With Examples)Understanding WINDOW in PostgreSQL (With Examples)Understanding PostgreSQL WITHIN GROUPUnderstanding DISTINCT in PostgreSQL (With Examples)Understanding WHERE in PostgreSQL (With Examples)Understanding OFFSET in PostgreSQL (With Examples)

Postgres joins

PostgreSQL Joins : A SummaryWhat Is a PostgreSQL Full Outer Join?What Is a PostgreSQL Cross Join?What Is a PostgreSQL Inner Join?What Is a PostgreSQL Left Join? And a Right Join?PostgreSQL Join Type TheoryStrategies for Improving Postgres JOIN Performance

Postgres operations

A Guide to PostgreSQL ViewsData Partitioning: What It Is and Why It MattersWhat Is Data Compression and How Does It Work?Self-Hosted or Cloud Database? A Countryside Reflection on Infrastructure Choices

More

Understanding ACID Compliance Structured vs. Semi-Structured vs. Unstructured Data in PostgreSQLUnderstanding Foreign Keys in PostgreSQL

Postgres functions

Understanding PostgreSQL FunctionsPostgreSQL Mathematical Functions: Enhancing Coding EfficiencyUsing PostgreSQL String Functions for Improved Data AnalysisData Processing With PostgreSQL Window FunctionsUnderstanding PostgreSQL Date and Time FunctionsUnderstanding the Postgres string_agg FunctionUnderstanding PostgreSQL User-Defined FunctionsUnderstanding PostgreSQL's COALESCE FunctionUnderstanding SQL Aggregate FunctionsUnderstanding percentile_cont() and percentile_disc() in PostgreSQLUnderstanding PostgreSQL Conditional FunctionsUnderstanding PostgreSQL Array FunctionsUnderstanding the Postgres extract() FunctionUnderstanding the rank() and dense_rank() Functions in PostgreSQL

Postgres statements

Understanding PostgreSQL SELECTUsing PostgreSQL UPDATE With JOINWhat Characters Are Allowed in PostgreSQL Strings?

Data analysis

What Is Data Transformation, and Why Is It Important?

Products

Time Series and Analytics AI and Vector Enterprise Plan Cloud Status Support Security Cloud Terms of Service

Learn

Documentation Blog Forum Tutorials Changelog Success Stories Time Series Database

Company

Contact Us Careers About Brand Community Code Of Conduct Events

Subscribe to the Tiger Data Newsletter

By submitting, you acknowledge Tiger Data's Privacy Policy

2025 (c) Timescale, Inc., d/b/a Tiger Data. All rights reserved.

Privacy preferences
LegalPrivacySitemap

Published at Apr 30, 2024

How to Address ‘Error: Could Not Resize Shared Memory Segment’

Try for free

Start supercharging your PostgreSQL today.

A fatal error red cross on a computer screen

Written by Sarah Conway

It’s a day like any other. You’re running PostgreSQL on a server when, all of a sudden, your memory usage spikes, operations stop, and you see the dreaded error message: “Could not resize shared memory segment.”

Luckily, it’s a fairly common memory fault encountered when using PostgreSQL. Let’s take a look at why it happens and how to address it.

What This Error Means

PostgreSQL uses shared memory to cache pages and execute queries. Because of this, database transactions are typically subject to system-wide allocation limits, meaning when a server detects that memory usage is exceeding the current setting, you’ll quickly be notified of the thrown error, and the system will refuse the requested operation. 

When you receive the error message…

ERROR:  could not resize shared memory segment... : No space left on device 

…this is an indication that Postgres ran into a problem with memory allocation on the device. Luckily, there’s a simple solution: you just need to adjust the memory limits set within your system! In this blog post, we’ll review a few of the ways you can do that in order to mitigate this error.

Most Common Problem: Shared Memory Parameter

We know that this error represents a performance bottleneck due to memory use. But what’s the actual cause of the problem?

Most commonly, there are system limits set for shared memory segment sizes. As an example, the Docker platform has a default shared memory size of 64 MB—a setting that’s easily able to be exceeded when running any kind of substantial workload or database operation. This default value does vary between each operating system; however, it’s typical for this setting to be too low to handle data at a large scale. 

First, you’ll need to start out by checking the current state of resource usage to determine if the operation you’re attempting is overloading the system. Take a look at your monitoring stack to see if there’s a bottleneck or high spike in usage, and note what value it’s attempting to exceed and for what query. This will allow you to add more memory or otherwise optimize queries as needed as you proceed with mitigating the error. Viewing logs will also give you more information about specific transactional statements that are getting locked or that are hanging for long periods of time due to this error.

There are specific PostgreSQL logging parameters that can be defined that will enable you to log related events for maximum observability in this situation, such as log_lock_waits = on (default off) to create an audit trail of events logged for queries that have been waiting for longer than the deadlock_timeout. 

You can maximize error output using log_error_verbosity and even control the types of SQL statements that get logged with log_statement (choosing between none, ddl, mod, and all), which is by default set to none. Modify these kinds of settings according to the level of detail you need to identify problematic queries or situations that need to be addressed in the context of resolving this error.

Once you’ve got a good idea of what’s actually happening within your system to trigger the error and have determined that the queries currently being executed are optimized and running as expected with an appropriate end result, you’ll want to take a look at Postgres resource consumption configuration parameters. 

You can start out by checking the current setting for shared_buffers (to set the memory limits for shared memory buffer use, default 128 MB). This value controls the data cache for Postgres and dictates the main allocation of shared memory that's made available at server start. It’s recommended by the Postgres docs to set this to around 25 percent of available memory usage when exceeding the current setting. It does, however, need to be at least slightly less than the current setting of shm_size (if applicable, when running on Docker systems).

Check out this blog post for more details on how to tune these key PostgreSQL parameters to improve your database performance.

work_mem should also be noted as it allows you to set the base maximum amount of memory to be used by a query operation before writing to the temporary disk (default 4 MB). Queries are allowed to use up to whatever the value is defined for work_mem on execution for each node and each process in the EXPLAIN plan. When many parallel worker operations are running or many tables and partitions are being handled, the amount of memory in use exponentially increases.

If you continue running into problems, you can also attempt disabling parallel queries to minimize concurrent operations and limit allowed operations to one query at a time. When parallel workers are enabled, queries are executed faster but consume more resources per transaction (thereby worsening overall throughput). This functionality can be controlled with the max_parallel_workers setting.

From the Lock Management section of the docs, you may also want to take a look at the current setting of max_locks_per_transaction. When iterating over a huge number of tables, this limit can restrict operations (causing this shared memory error). This happens most often when running logical backups, as pg_dump locks tables throughout the backup, which can easily trigger this error. 

Read this article to better understand PostgreSQL locks.

Of course, reading the Postgres docs (linked for each above) is highly recommended when deciding how best to calculate all of these values, as there’s usually specific math performed or other special considerations that need to be factored in to optimize memory allocation settings. 

Additionally, per each operating system or development platform, you’ll need to identify what shared memory parameter will need to be adjusted and size it up accordingly. For this kind of change, you’ll need to restart your system or rebuild your cloud instance once the setting is adjusted for it to take effect.

As a result, take your time to look into platform-specific documentation. These localized configuration files are designed to override Postgres defaults and dynamically allocate resources, so even if you alter the primary configuration files, you may still run into this shared memory error. 

You can usually change these settings by passing in a flag to the interactive server start command (in Docker, --shm-size=256MB passed as a command line flag to docker run, for example) or by altering applicable values within the main configuration file for that platform (such as in docker-compose, where the shm_size parameter will set the global default for memory). 

Be sure to keep in mind that some cloud database platforms do leverage dynamic resource management (such as Google Cloud E2 VM instances) so you may find that your changes are consistently overwritten. If you continue to run into errors or related problems, you should seek support directly from your cloud vendor that’s hosting your PostgreSQL databases to identify additional settings that might need to be adjusted to resolve this error.

What About Timescale?

Our cloud service Timescale operates as an extension on top of PostgreSQL. Therefore, any advice recommended for errors seen in Postgres (including the contents of this blog post!) will still be directly helpful for your situation. You’ll still want to look at current memory and resource consumption, identify queries triggering the error, and investigate the suggested memory settings described above that are used natively within Postgres to resolve the observed memory error.

For additional advice on Timescale-specific parameters that would be helpful to take note of and adjust accordingly for maximizing performance and minimizing errors, check out our related blog "Timescale Parameters You Should Know About (and Tune) to Maximize Your Performance." 

Conclusion

While it can be conceptually simple to understand the cause of this memory error, it is more difficult to calculate how resources should be allocated—especially when seeking to make these settings as cost-efficient and performant as possible for your exact use case. Staying on top of monitoring and observability within your infrastructure is the best starting place for understanding usage patterns and requirements for day-to-day operations, especially as your data use grows over time.

Using a cloud service like Timescale can help with this effort. With our offering, you get out-of-the-box monitoring dashboards for databases using Insights, features oriented specifically for database monitoring and query optimization. With Timescale’s Support team, you can save time and money for innovation and expedite time-to-market with complete peace of mind using this built-in functionality, knowing that Postgres experts are here to help. Not already using PostgreSQL or Timescale, but want to be? Migration assistance is included with support plans to help you ensure a seamless transition from one platform to another. 

Sound interesting? Or, do you have any questions about how to resolve this error or otherwise optimize memory and resource settings within PostgreSQL and Timescale? Our team is here to help! If you're currently an active user of Timescale, you are able to get access to our support with your base plan. Email us anytime at support@timescale.com. Otherwise, you can give Timescale a try free for 30 days with no credit card entry required (and get full access to our expert support during the trial, too!). 

We’re looking forward to connecting with you! 

On this page

    Try for free

    Start supercharging your PostgreSQL today.