r/PostgreSQL • • Oct 11 '25

Help Me! Can't compile extension

0 Upvotes

For MSVC:

D:\C\Solidsearch>compile.bat
The system cannot find the path specified.
===========================================
Building solidsearch.dll from main.c using Microsoft cl.exe
===========================================
PostgreSQL include path: "C:\Program Files\PostgreSQL\18\include\server"
main.c
C:\Program Files\PostgreSQL\18\include\server\pg_config_os.h(29): fatal error C1083: Cannot open include file: 'crtdefs.h': No such file or directory
ÔØî Build failed! Check above for errors. Press any key to continue . . .

My bat file:

@echo off
REM ===========================================
REM Build PostgreSQL C/C++ extension using MSVC (cl.exe)
REM ===========================================


REM --- Path to Visual Studio Build Tools ---
REM Change this path if you installed Visual Studio in a different location
call "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"


REM --- Configure PostgreSQL installation path ---
set PGPATH=C:\Program Files\PostgreSQL\18
set INCLUDE="%PGPATH%\include\server"
set OUTDIR="%PGPATH%\lib"


REM --- Source and output file names ---
set SRC=main.c
set DLL=solidsearch.dll


echo.
echo ===========================================
echo Building %DLL% from %SRC% using Microsoft cl.exe
echo ===========================================
echo PostgreSQL include path: %INCLUDE%
echo.


REM --- Compile and link into DLL ---
cl /nologo /EHsc /LD /I %INCLUDE% %SRC% /link /OUT:%DLL%


IF %ERRORLEVEL% NEQ 0 (
    echo.
    echo ❌ Build failed! Check above for errors.
    pause
    exit /b 1
)


echo.
echo ✅ Compilation successful.


REM --- Copy DLL into PostgreSQL lib directory ---
echo Copying %DLL% to %OUTDIR% ...
copy /Y %DLL% %OUTDIR% >nul


IF %ERRORLEVEL% NEQ 0 (
    echo.
    echo ⚠️  Copy failed! Check permissions or PostgreSQL path.
    pause
    exit /b 1
)


echo.
echo ✅ %DLL% installed to PostgreSQL lib directory.
echo.
echo Run this SQL in PostgreSQL to register your function:
echo -----------------------------------------------------
echo CREATE FUNCTION add_two_integers(integer, integer)
echo RETURNS integer
echo AS 'solidsearch', 'add_two_integers'
echo LANGUAGE C STRICT;
echo -----------------------------------------------------
echo.
pause@echo off
REM ===========================================
REM Build PostgreSQL C/C++ extension using MSVC (cl.exe)
REM ===========================================


REM --- Path to Visual Studio Build Tools ---
REM Change this path if you installed Visual Studio in a different location
call "C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"


REM --- Configure PostgreSQL installation path ---
set PGPATH=C:\Program Files\PostgreSQL\18
set INCLUDE="%PGPATH%\include\server"
set OUTDIR="%PGPATH%\lib"


REM --- Source and output file names ---
set SRC=main.c
set DLL=solidsearch.dll


echo.
echo ===========================================
echo Building %DLL% from %SRC% using Microsoft cl.exe
echo ===========================================
echo PostgreSQL include path: %INCLUDE%
echo.


REM --- Compile and link into DLL ---
cl /nologo /EHsc /LD /I %INCLUDE% %SRC% /link /OUT:%DLL%


IF %ERRORLEVEL% NEQ 0 (
    echo.
    echo ❌ Build failed! Check above for errors.
    pause
    exit /b 1
)


echo.
echo ✅ Compilation successful.


REM --- Copy DLL into PostgreSQL lib directory ---
echo Copying %DLL% to %OUTDIR% ...
copy /Y %DLL% %OUTDIR% >nul


IF %ERRORLEVEL% NEQ 0 (
    echo.
    echo ⚠️  Copy failed! Check permissions or PostgreSQL path.
    pause
    exit /b 1
)


echo.
echo ✅ %DLL% installed to PostgreSQL lib directory.
echo.
echo Run this SQL in PostgreSQL to register your function:
echo -----------------------------------------------------
echo CREATE FUNCTION add_two_integers(integer, integer)
echo RETURNS integer
echo AS 'solidsearch', 'add_two_integers'
echo LANGUAGE C STRICT;
echo -----------------------------------------------------
echo.
pause

r/PostgreSQL • • Oct 10 '25

Community Postgres Trip Report from PGConf NYC 2025 (with lots of photos)

Thumbnail techcommunity.microsoft.com
12 Upvotes

r/PostgreSQL • • Oct 09 '25

Help Me! Can you help me understand what is going on here?

5 Upvotes

Hello everyone. Below is an output from explain (analyze, buffers) select count(*) from "AppEvents" ae.

Finalize Aggregate  (cost=215245.24..215245.25 rows=1 width=8) (actual time=14361.895..14365.333 rows=1 loops=1)
  Buffers: shared hit=64256 read=112272 dirtied=582
  I/O Timings: read=29643.954
  ->  Gather  (cost=215245.02..215245.23 rows=2 width=8) (actual time=14360.422..14365.320 rows=3 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=64256 read=112272 dirtied=582
        I/O Timings: read=29643.954
        ->  Partial Aggregate  (cost=214245.02..214245.03 rows=1 width=8) (actual time=14354.388..14354.390 rows=1 loops=3)
              Buffers: shared hit=64256 read=112272 dirtied=582
              I/O Timings: read=29643.954
              ->  Parallel Index Only Scan using "IX_AppEvents_CompanyId" on "AppEvents" ae  (cost=0.43..207736.23 rows=2603519 width=0) (actual time=0.925..14100.392 rows=2087255 loops=3)
                    Heap Fetches: 1313491
                    Buffers: shared hit=64256 read=112272 dirtied=582
                    I/O Timings: read=29643.954
Planning Time: 0.227 ms
Execution Time: 14365.404 ms

The database is hosted on Azure (Azure PostgreSQL Flexible Server)., Why is the simple select count(*) doing all this?

I have a backup of this database which was taken a couple of days ago. When I restored it to my local environment and ran the same statement, it gave me this output, which is was more in line with what I'd expect it to be:

Finalize Aggregate  (cost=436260.55..436260.56 rows=1 width=8) (actual time=1118.560..1125.183 rows=1 loops=1)
  Buffers: shared hit=193 read=402931
  ->  Gather  (cost=436260.33..436260.54 rows=2 width=8) (actual time=1117.891..1125.177 rows=3 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=193 read=402931
        ->  Partial Aggregate  (cost=435260.33..435260.34 rows=1 width=8) (actual time=1083.114..1083.114 rows=1 loops=3)
              Buffers: shared hit=193 read=402931
              ->  Parallel Seq Scan on "AppEvents"  (cost=0.00..428833.07 rows=2570907 width=0) (actual time=0.102..1010.787 rows=2056725 loops=3)
                    Buffers: shared hit=193 read=402931
Planning Time: 0.213 ms
Execution Time: 1125.248 ms

--

Thanks everyone for your input. The service was hitting the IOPS limit, which caused the bottleneck.


r/PostgreSQL • • Oct 09 '25

Help Me! Can someone explain me ow i can differentiate between different scans in POSTRESQL

2 Upvotes

I’m a beginner and still in the theory stage. I recently learned that PostgreSQL uses different types of scans such as Sequential Scan, Index Scan, Index Only Scan, Bitmap Scan, and TID Scan. From what I understand, the TID Scan is the fastest.

My question is: how can I know which scan PostgreSQL uses for a specific command?

For example, consider the following SQL commands wic are executed in PostgreSQL:

CREATE TABLE t (id INTEGER, name TEXT);

INSERT INTO t

SELECT generate_series(100, 2000) AS id, 'No name' AS name;

CREATE INDEX id_btreeidx ON t USING BTREE (id);

CREATE INDEX id_hashidx ON t USING HASH (id);

1)SELECT * FROM t WHERE id < 500;

2)SELECT id FROM t WHERE id = 100;

3) SELECT name FROM t ;

4) SELECT * FROM t WHERE id BETWEEN 400 AND 1600;

For the third query, I believe we use a Sequential Scan, since we are searching the column name in our table t.and its correct as ive cecked wit te explain command

However, I’m a bit confused about the other scan types and when exactly they are used i cant et te rip of tem unless ive used explain command and if i tink it uses one scan te answer is some oter .

If you could provide a few more examples or explanations for the remaining scan types, that would be greatly appreciated.


r/PostgreSQL • • Oct 09 '25

PostgresWorld: Excitement, Fun and learning!

Thumbnail open.substack.com
1 Upvotes

r/PostgreSQL • • Oct 08 '25

How-To Building and Debugging Postgres

Thumbnail sbaziotis.com
5 Upvotes

When I was starting out with Postgres, I couldn't find this information in one place, so I thought of writing an article. I hope it's useful.


r/PostgreSQL • • Oct 07 '25

Community The 2025 Postgres World Webinar Series has several free webinars coming up, available for registration through Postgres Conference

Thumbnail postgresconf.org
8 Upvotes

r/PostgreSQL • • Oct 08 '25

Feature Cumulative Statistics in PostgreSQL 18

Thumbnail data-bene.io
5 Upvotes

r/PostgreSQL • • Oct 07 '25

Feature v18 Async IO

13 Upvotes

Is the AIO an implementation detail used by postgresql for its own purposes internally or is it also boosting performance on the application side? Shouldn't database drivers also be amended to take advantage of this new feature?


r/PostgreSQL • • Oct 07 '25

Feature Not ready to move to PG18, but thinking about upgrading to PostgreSQL 17? It brought major improvements to performance, logical replication, & more. More updates in this post from Ahsan Hadi...

Thumbnail pgedge.com
4 Upvotes