How to generate a Aurora Postgresql cluster with all auto explain enabled

PostgreSQL has query execution plans configured as extension, meaning they do not come out of the box we need to configure it, For on-prem or owning server you can check this link which tells how to configure it. Problem is there are so many steps. And it is confusing for AWS Aurora I wrote a small bash script Here just to make this work automatic. Here is powershell version SubnetGroupName -> AWS subnet name for connecting which has all the configuration ready $psqlPath = “C:\tools\postgresql-16.6-2\pgsql\bin\psql.exe” -> user should have psql in the machine and change the path accordingly Before starting it, user should have aws secret and keys defined in their env variables, explained here After successful execution you should see the test cluster like below, and you can check logs to see how execution plans are created. ...

December 11, 2024 · 1 min · Özkan Pakdil

HashMap collisions and how JDK handles it

I was thinking on this question How does HashMap handle collisions internally? What changes were introduced in Java 8 for its implementation? and reading this blog says On a final note, from Java 8, the linked lists are dynamically replaced with balanced binary search trees in collision resolution after the number of collisions in a given bucket location exceed a certain threshold. Than I wonder how it works and went and found the source code of hash map in openjdk. It is a very long class, almost 2600 lines, but so many comments 🤓 it is not very common to see this much comment in a java code, anyway then I start reading it and wanted to note down how it behaves on collusion ...

November 27, 2024 · 3 min · Özkan Pakdil

FFM (Foreign Function and Memory) Stdlib Example

FFM is the new API trying to replace JNI and jep is here It is basically calling functions outside of JVM or accessing memory not managed by JVM. I wanted to test can FFM beat regular Java API, below you can find a simple test doing math sin with FFM and with regular Math.sin import java.lang.foreign.FunctionDescriptor; import java.lang.foreign.Linker; import java.lang.foreign.MemorySegment; import java.lang.foreign.SymbolLookup; import java.lang.foreign.ValueLayout; public class FFMSinTest { public static void main(String[] args) throws Throwable { Linker linker = Linker.nativeLinker(); SymbolLookup stdlib = linker.defaultLookup(); // Locate the "sin" function in the C math library MemorySegment sinAddress = stdlib.find("sin").orElseThrow(); FunctionDescriptor descriptor = FunctionDescriptor.of(ValueLayout.JAVA_DOUBLE, ValueLayout.JAVA_DOUBLE); var sinHandle = linker.downcallHandle(sinAddress, descriptor); double angle = Math.PI / 4; // 45 degrees in radians // Timing Java's Math.sin() long javaStartTime = System.nanoTime(); for (int i = 0; i < 1_000_000; i++) { double result = Math.sin(angle); } long javaEndTime = System.nanoTime(); long javaDuration = javaEndTime - javaStartTime; // Timing C sin via FFM long ffmStartTime = System.nanoTime(); for (int i = 0; i < 1_000_000; i++) { double result = (double) sinHandle.invoke(angle); } long ffmEndTime = System.nanoTime(); long ffmDuration = ffmEndTime - ffmStartTime; System.out.println("Java Math.sin() took: " + javaDuration / 1_000_000.0 + " ms"); System.out.println("C sin (FFM) took: " + ffmDuration / 1_000_000.0 + " ms"); } } And result is ...

November 11, 2024 · 2 min · Özkan Pakdil

How to disable win11 startmenu internet search

Whenever I search anything on the start menu it triggers an internet search at the back and brings some results and suggestions from web, I use browser to do internet things, when we start mixing that to regular windows programs that slows down the computer, and I do not like slow windows. Below you can find a way to disable that online search. @echo off :: Check if running as administrator net session >nul 2>&1 if %errorLevel% NEQ 0 ( echo Requesting administrator privileges... powershell -Command "Start-Process '%0' -Verb RunAs" exit /b ) REM Disable Search the Web in Windows 11 REM Create the registry key if it doesn't exist reg add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /f REM Set DisableSearchBoxSuggestions to 1 reg add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f echo "Search the Web in Windows 11 has been disabled. Please sign out and sign back in to apply changes." pause Put this script into any .bat file and run it in windows11 and logoff login or restart your machine and start menu works faster after that. It still search in the computer that maybe disabled too but that is for another blog post. ...

November 7, 2024 · 1 min · Özkan Pakdil

How to Use Lunr.js for Searching in a Jekyll Blog

I have been using Google Programmable Search Engine on my blog, but I found that it doesn’t work quite as I expected. First, I tried Bing and DuckDuckGo as alternatives, but none of them performed as desired. DuckDuckGo’s API is nice, but it lacks a ‘site:’ filter, which prevented it from working as needed. Here are the steps to set up a Jekyll search system using Lunr.js for GitHub Pages(github.io): Create js/search.js and add this code Add search.md to the root of your project. Add an HTML form where you like <li class="nav-item my-auto"> <div class="header-search"> <form class="header-search-form" action="/search.html" method="get"> <input type="text" id="search-box" name="query"> <input type="submit" value="search"> </form> </div> </li> Check here for example. ...

November 5, 2024 · 1 min · Özkan Pakdil