{"id":19778426,"url":"https://github.com/evancarroll/pg-srf-repeat-benchmark","last_synced_at":"2025-07-05T02:05:19.634Z","repository":{"id":52789494,"uuid":"423019604","full_name":"EvanCarroll/pg-srf-repeat-benchmark","owner":"EvanCarroll","description":"A testing repo comparing an SRF that is dually implemented as ValuePerCall and Materialize","archived":false,"fork":false,"pushed_at":"2021-11-08T02:00:12.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T13:52:13.263Z","etag":null,"topics":["benchmark","c","c-language","postgresql","postgresql-extension","sql"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EvanCarroll.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-31T00:30:25.000Z","updated_at":"2023-12-18T15:24:50.000Z","dependencies_parsed_at":"2022-08-22T18:20:16.752Z","dependency_job_id":null,"html_url":"https://github.com/EvanCarroll/pg-srf-repeat-benchmark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EvanCarroll/pg-srf-repeat-benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanCarroll%2Fpg-srf-repeat-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanCarroll%2Fpg-srf-repeat-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanCarroll%2Fpg-srf-repeat-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanCarroll%2Fpg-srf-repeat-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvanCarroll","download_url":"https://codeload.github.com/EvanCarroll/pg-srf-repeat-benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvanCarroll%2Fpg-srf-repeat-benchmark/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263646537,"owners_count":23494007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","c","c-language","postgresql","postgresql-extension","sql"],"created_at":"2024-11-12T05:29:26.623Z","updated_at":"2025-07-05T02:05:19.609Z","avatar_url":"https://github.com/EvanCarroll.png","language":"C","readme":"PostgreSQL Set-Returning-Function (SRF) C-Extension Benchmarks\n====\n\nThis repo consists of multiple implementations of a simple SRF that repeats it\ninput.\n\n    repeat_implementation( what int4, row_count int4 )\n\nThe output of this function is a set of `row_count` rows of int4 columns that\njust repeat `what`.\n\nImplementations\n====\n\nThere are three current implementations both with the same signature described above.\n\n* [`repeat_materialize`](./implementations/materialize.c) (`SFRM_Materialize`)\n* [`repeat_valuepercall`](./implementations/valuepercall.c) (`SFRM_ValuePerCall`)\n* [`repeat_materialize_preferred`](implementations/materialize_preferred.c) (`SFRM_Materialize_Preferred`)\n\nRaison d'être\n====\n\nThis exists because the [doc says,](https://www.postgresql.org/docs/current/xfunc-c.html)\n\n\u003e C-language functions have two options for returning sets (multiple rows). In\n\u003e one method, called **`ValuePerCall`** mode, a set-returning function is called\n\u003e repeatedly (passing the same arguments each time) and it returns one new row\n\u003e on each call, until it has no more rows to return and signals that by\n\u003e returning NULL. The set-returning function (SRF) must therefore save enough\n\u003e state across calls to remember what it was doing and return the correct next\n\u003e item on each call. In the other method, called **`Materialize`** mode, an SRF fills\n\u003e and returns a tuplestore object containing its entire result; then only one\n\u003e call occurs for the whole result, and no inter-call state is needed.\n\n[I asked under which case would the performance of one be greater than the\nother.](https://dba.stackexchange.com/q/301920/2639) There was almost no\ndocumentation advising one or the other for performance, so I created this repo\nto help understand the call-convention overhead of these two methods.\n\n\nResearch\n====\n\n* [`src/backend/utils/fmgr/README`](https://github.com/postgres/postgres/blob/master/src/backend/utils/fmgr/README)\n\nPatches Accepted\n====\n\nPlease open up issues if any of these examples can be reduced in complexity or\nmade more performant.\n\n**Idiot disclaimer: I really don't have any idea what I'm doing.**\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevancarroll%2Fpg-srf-repeat-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevancarroll%2Fpg-srf-repeat-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevancarroll%2Fpg-srf-repeat-benchmark/lists"}