<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tales Cione on Medium]]></title>
        <description><![CDATA[Stories by Tales Cione on Medium]]></description>
        <link>https://medium.com/@tcione?source=rss-14c939ef7b5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wUnpH2dVdZmNmg_cfyYa6w.jpeg</url>
            <title>Stories by Tales Cione on Medium</title>
            <link>https://medium.com/@tcione?source=rss-14c939ef7b5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 14:04:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tcione/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Managing code work with feature Branches]]></title>
            <link>https://medium.com/heyjobs-tech/managing-code-work-with-feature-branches-c08070065d5d?source=rss-14c939ef7b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c08070065d5d</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code-collaboration]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[feature-branch]]></category>
            <dc:creator><![CDATA[Tales Cione]]></dc:creator>
            <pubDate>Mon, 30 May 2022 14:29:09 GMT</pubDate>
            <atom:updated>2023-02-15T19:39:37.015Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lzATKjXvZ9IE5Jq3UknSig.jpeg" /><figcaption>Photo by<a href="https://unsplash.com/@anniespratt?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"> Annie Spratt</a> on<a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"> Unsplash</a></figcaption></figure><p>There are<a href="https://www.atlassian.com/git/tutorials/comparing-workflows"> several ways</a> to develop software in a collaborative environment. One common workflow is leveraging “Feature Branches”. What are those, you might ask?</p><p>To simplify it a lot, they are software work (normally features) developed in dedicated branches and then submitted for review. Once the code is reviewed, one should update it using the latest main branch,<a href="https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase"> rebase</a> and merge.</p><p>This method has two advantages:</p><ul><li>It structures a practical way for developers to build things in parallel</li><li>Creates potential for a sensible commit history in the main branch¹</li></ul><p>Neat, huh? Not all of it, though. Sometimes feature branches can foster problems. As they grow in age and size, coalescing becomes harder. At some point, things get so different that we have to dedicate days to making that feature branch production-ready.</p><p>A disclosure before we continue: if your feature is just small, feel free to ignore everything that follows. Just create your branch, deploy your feature and move on 😬. That said, let’s go!</p><p>How can we use this strategy without harming our projects? <strong>The preferable thing would be to break down your development into small, independent, and functional pieces as much as possible</strong>. When impossible, still use long-lived feature branches, but employ some tactics to make it manageable. Let’s start by talking about breaking things down.</p><h3>On breaking things down</h3><p>When it comes to dividing work, it can be useful to ask three questions:</p><ol><li>Can I deploy this in isolation?</li><li>If not, can I deploy it in a way that they peacefully interact with other pieces?</li><li>If not, can I switch the pieces off on demand?</li></ol><p>To answer these questions, I need to define what isolation, peacefulness, and switching things off mean to me.</p><h4>Isolated pieces</h4><p>The main idea of this tactic is to try to break down work into pieces that <strong>can be deployed to production</strong>. However, <strong>are unreachable by the users and active procedures</strong>. They are just hanging around in isolation, eagerly waiting to be integrated. Some examples can be:</p><ul><li>Introduction of new API endpoints</li><li>Introduction of new tables or columns</li><li>Refactorings² that will help that feature’s development</li></ul><h4>Peaceful pieces</h4><p>We can employ this tactic whenever we can deploy pieces that are exposed and integrated but do not have a direct effect on current user experience or procedures. Some examples can be:</p><ul><li>Calculating values once an entity is saved to the database</li><li>REST API fields can be introduced with default values</li><li>Changes in internal APIs that can be temporary integrated using <a href="https://refactoring.guru/design-patterns/structural-patterns">structural design patterns</a> like <a href="https://refactoring.guru/design-patterns/facade">Facades</a></li></ul><h4>Switched off pieces</h4><p>There are times that we can break it down, but the change is impossible to separate from existing behavior. For those cases, we can leverage feature flags.<a href="https://www.growthbook.io/"> There</a><a href="https://www.getunleash.io/"> are</a><a href="https://launchdarkly.com/"> several</a> robust options here, nonetheless, good ole ENV variables can do the trick as well. <strong>The downside is that we have to maintain two implementations at the same time (the one currently active and the one hidden under the flag)</strong>. Some examples can be:</p><ul><li>Doing UI changes per component and then making them available all at once</li><li>Doing significant changes to one API endpoint before the API consumers can be adapted</li><li>Adding support for new devices, browsers, and/or users of different regions</li></ul><p>Now, what if even after carefully considering these breakdown possibilities, we still think we’ll need a long-lived branch? Well, our only option is to make it bearable :). But… how?</p><h3>On managing the unavoidable long-lived branches</h3><p>As with everything, there is not a single answer. I can, however, tell you the things that worked well for me so far. I’ve come to organize my opinions into five rules.</p><h4>1. Keep it updated in relation to your main branch</h4><p>Failing to do so will cause you lots of headaches. The number of conflicts after being separated from the main branch can be overwhelming and their resolution might end up consuming lots of testing hours.</p><h4>2. Keep your tests green</h4><p>Related to (1). Make sure that tests always pass. From my experience, it’s preferable to constantly rework tests, than to fix a myriad of failing tests. It gets really hard to discern what is no longer relevant, what’s broken, and which new tests should be introduced.</p><h4>3. Implement changes via smaller branches</h4><p>Pick up work that’s big enough to be its own thing, but small enough to not be manageable to reviewers³, The <a href="https://en.wikipedia.org/wiki/Single-responsibility_principle">single responsibility principle</a> is a good way to define what a smaller branch can contain. If it does more than one thing, you might want to consider breaking it down. If it’s too small to do something independently, then it becomes meaningless.</p><h4>4. Avoid rebasing before work is over</h4><p>Keeping a track record of what was done and where the changes came from helps in the long run. Opinions might differ here, but in case you’d prefer rebasing, try to include references to PRs that were merged in that branch.</p><h4>5. Perform QA only against the long-lived branch</h4><p>If we’re using a long-lived branch, chances are that what we’re working on only makes sense as a single, concise package. So we should treat it as such when doing quality assurance. Outside of that testing, smaller branches in isolation can get confusing fast. Merging to the long-lived branch might introduce regressions or even new bugs afterward.</p><h3>Outro</h3><p>Oof, that was a lot. Collaboration can be one of the more challenging aspects of software development, and it tends to get more complex as the team and software grows. Hopefully, this article has offered applicable ways to help you and your team to manage the ever-growing complexity of your coding stuff :)</p><p>[1]: What is a good commitment message and how to maintain a healthy git history are beyond the scope of this article. HOWEVER, I do encourage the watching of<a href="https://www.youtube.com/watch?v=1NoNTqank_U"> “A Branch in Time” by Tekin Süleyman in 2019’s Rubyconf AU</a></p><p>[2]:<a href="https://martinfowler.com/bliki/DefinitionOfRefactoring.html"> As defined by Martin Fowler</a>, meaning there will be no changes in input and output.</p><p>[3]: Huge PRs tend to be overwhelming. This encourages the reviewer to yield by typing “LGTM”</p><p>Interested in joining our team? <a href="https://hire.heyjobs.co/en-us/careers">Browse our open positions</a> or check out what we do at <a href="https://www.heyjobs.co/en-de">HeyJobs</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c08070065d5d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/heyjobs-tech/managing-code-work-with-feature-branches-c08070065d5d">Managing code work with feature Branches</a> was originally published in <a href="https://medium.com/heyjobs-tech">HeyJobs Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A gentle introduction to PostgreSQL indexes]]></title>
            <link>https://medium.com/heyjobs-tech/a-gentle-introduction-to-postgresql-indexes-fc58a2f5ba96?source=rss-14c939ef7b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc58a2f5ba96</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[index]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Tales Cione]]></dc:creator>
            <pubDate>Mon, 31 Aug 2020 06:01:01 GMT</pubDate>
            <atom:updated>2023-02-15T19:39:13.894Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="Files ordered by color in a shelf" src="https://cdn-images-1.medium.com/max/1024/1*0X-pNeFVsj_4w0nC1qKC8Q.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mvdheuvel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Maarten van den Heuvel</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>So, Indexes, am I right? Indexes are everywhere in relational databases, if you have ever worked with one, you may have thought about them to some extent. If you haven’t yet, you probably will at some point.</p><p>This article’s objective is to give you a brief overview of what indexes are and which indexes are available for PostgreSQL users. Alright, let’s go!</p><h3>What are indexes, and what are they for?</h3><p>Indexes in our database tables have the same function as the indexes we use in our physical books. They help us to find things faster by providing a point of reference. That way, we can zoom to the result we want instead of looking for it entry by entry (also known as a <strong>sequential scan</strong> or <strong>full table scan</strong>).</p><p>That’s made possible by the magical use of caching. Whenever you define an index, the <strong>Relational Database Management System</strong> (RDBMS, for short, a role filled later in this article by PostgreSQL) stores the values separately using a specific data structure. Whenever you ask it to filter something, it knows where it’s stored and how to efficiently look for it.</p><p>That’s very cool, no? You know what also is very cool about this? It is that it brings us to our next topic.</p><h3>When indexes are used and what are their side effects</h3><p>As in any magical thing, there are conditions to follow and trades to do.</p><h4>Let’s start by the conditions</h4><ul><li>When creating indexes, you must define what you’re indexing. It can be one or multiple columns. You can also add constraints like uniqueness (which can also be used to guarantee data integrity) and/or conditions in which that index is stored (i.e., only store indexes when a particular column equals a specific value). It’s worth mentioning that whenever you create a primary key or add a uniqueness constraint, an implicit index is devised for those columns.</li><li>For you to actually use your indexes, you must be either filtering or sorting data.</li><li>Creating an index doesn’t guarantee that it’ll be used by your RDBMS. Every RDBMS has something called a query planner. The query planner decides the best strategy to use, considering things like available capacity and table size.</li></ul><h4>And let’s finish with the trade-offs</h4><p>Remember that I’ve mentioned that indexes are stored using specific data structures? That means that whenever you are inserting or updating those indexed columns, your RDBMS will update those stored indexes.</p><p>It’ll go through the stored values and decide the best place to put that new value. For that, adding indexes might mean slower inserts, updates, and deletes. Although this is rarely a big problem, it’s something worth considering when adding new indexes.</p><p>One last thing to consider is that every index you add will take disk space as well. Again, usually not a big problem, but it’s a good thing to keep in mind.</p><p>With all that out of our way, let’s move to the next section.</p><h3><strong>A brief tour through the index access methods offered by PostgreSQL</strong></h3><figure><img alt="Board game map with train lines filled with tiny trains of multiple colors" src="https://cdn-images-1.medium.com/max/1024/1*dQbAMfOBN15uDPgAoiVCTw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mirapolis?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Dave Photoz</a> on <a href="https://unsplash.com/s/photos/board-games?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h4><strong>There are 6 built-in index access methods:</strong></h4><ol><li>B-Tree (or balanced tree)</li><li>Hash</li><li>GiST</li><li>SP-GiST</li><li>GIN</li><li>BRIN</li></ol><h4><strong>B-Tree (or Balanced tree)</strong></h4><p>B-Tree indexes are the default index type in PostgreSQL. Reason for that being that they fit well into most scenarios. Balanced trees indexes organize data using a <a href="https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree">self-balancing binary search tree</a>.</p><p>It’s a type of index that’s great for comparison operators (&lt; &lt;= = &gt;= &gt; BETWEEN) and to test presence (IS NULL, IS NOT NULL, IN).</p><p>Since this is Postgres’ default access method, to create a B-Tree index, one must simply create it:</p><pre>CREATE INDEX index_name ON table_name(column_name, …);</pre><p>For the sake of being thorough, let’s also see how to explicitly create the index:</p><pre>CREATE INDEX index_name ON table_name USING BTREE (column_name, …);</pre><h4><strong>Hash</strong></h4><p>Hash indexes store the indexes, well, using hashes, and their usage is limited to the equality operator (=). Even though B-Tree indexes cover the same usage, Hash indexes are faster and take less space, since looking up in hashes is way cheaper than looking up in trees.</p><p>Creating a hash index is similar to creating a B-Tree index as well:</p><pre>CREATE INDEX index_name ON table_name USING HASH (column_name, …);</pre><p>That said, it’s important to mention that <strong>hash indexes are not recommended for those using a PostgreSQL 9.x and below</strong>. The reason for that is because they are not crash-safe in those versions, meaning that if your RDBMS crashes for any reason, the hash indexes will have to be recreated.</p><h4>GIN</h4><p>GIN stands for Generalized Inverted Index. This type of index can be used to make full-text searches faster. The way it works is that it creates one index per word coupled with its matching locations (that’s why it’s an inverted index).</p><p>The catch here is that you can only index <a href="https://www.postgresql.org/docs/10/datatype-textsearch.html">tsvector</a> type columns with this access method. Aside from LIKE and ILIKE, there are many <a href="https://www.postgresql.org/docs/12/functions-textsearch.html">interesting operators that can be used</a>.</p><p>Now, how do I create one of those? Differently from Hash and B-Tree indexes, this one requires a bit more work:</p><ol><li>You must create a tsvector column. If you have a text column that you want to index, you can convert it using to_tsvector(language, text). Examples: to_tsvector(&#39;portuguese&#39;, &#39;O rato roeu a roupa do rei de Roma&#39;), to_tsvector(‘english’, ‘The quick brown fox jumped over the lazy dog.&#39;)</li><li>You must make sure that this new column is always up to date with the source column (if there is a source column, of course). (From PostgreSQL 12 onwards you can use <a href="https://www.postgresql.org/docs/12/ddl-generated-columns.html">Generated Columns</a> for that</li><li>Now you can finally create your GIN index:</li></ol><pre>CREATE INDEX index_name ON table_name USING GIN (column_name);</pre><h4>GiST</h4><p>GiST stands for Generalized Search Tree. This index can also be used to improve full-text searches but stores its references using a height-balanced tree.</p><p>GiST indexes are lossy (I won’t get into detail why, but you can read it <a href="https://www.postgresql.org/docs/9.1/textsearch-indexes.html">here</a> or <a href="https://habr.com/ru/company/postgrespro/blog/444742/">here</a>). This means that the initial result can contain false positives. To eliminate those, PostgreSQL checks if the results actually match the set conditions afterward.</p><p>Unlike GIN, we can index not only tsvector type columns, but also <a href="https://www.postgresql.org/docs/10/datatype-textsearch.html">tsquery</a> type columns.</p><p>Why would you use GiST over GIN, if one is lossy and the other is not? Well, here are some things to consider:</p><ul><li>GIN indexes are slower to create, so writes are slower</li><li>GIN indexes are faster to fetch since there will be no additional fetches</li><li>GIN indexes occupy more disk space</li><li>GiST indexes are better for dynamic data if the number of words stays under 100,000</li></ul><p>As creational steps go, GiST is also similar to GIN:</p><ol><li>You must create a tsvector or a tsquery column (you can create tsquery columns using to_tsquery. It takes the same parameters as to_tsvector)</li><li>You must make sure this new column is always up to date</li><li>You can run the following code to create the index:</li></ol><pre>CREATE INDEX index_name ON table_name USING GIST (column_name);</pre><p>On a side note, the GiST index can also work well for geospatial data types, but I won’t get into that part. If you wish to, a LOT can be read <a href="https://habr.com/ru/company/postgrespro/blog/444742/">here</a>.</p><h4>SP-GiST</h4><p>SP-GiST stands for space-partitioned GiST. Its strong suit is when indexing data that can be divided into non-intersecting clusters. Cities are an example of something that can be organized into non-intersecting groups since cities cannot belong to 2 countries or 2 regions.</p><p>So getting more technical again, this type of index is suitable for <a href="https://en.wikipedia.org/wiki/Quadtree">quadtrees</a> (made possible by using point type columns), <a href="https://en.wikipedia.org/wiki/K-d_tree">k-dimensional trees</a> (made possible by using point type columns), and <a href="https://en.wikipedia.org/wiki/Radix_tree">radix trees</a> (made possible by using text type columns). The last one would fit well into our cities example if cities were described using the following format: COUNTRY/REGION/CITY.</p><p>Since I don’t fully understand this index myself, I’ll just leave an example SQL for its creation and then refer to 2 extensive articles in which you can get very familiar with this access method:</p><pre>CREATE INDEX index_name ON table_name USING SPGIST (column_name);</pre><p>And the articles:</p><ul><li><a href="https://habr.com/ru/company/postgrespro/blog/446624/">Indexes in PostgreSQL — 6 (SP-GiST)</a></li><li><a href="https://www.cs.purdue.edu/spgist/papers/icde06.pdf">Space-partioning Trees in PostgreSQL: Realization and Performance</a></li></ul><h4>BRIN</h4><p>BRIN stands for Block Range Index. BRIN indexes are perfect when the indexed column value maps closely to its actual position in the table. It organizes data in blocks and registers the minimum and the maximum value contained in that block. With that information, PostgreSQL can efficiently scan only the data it actually needs to.</p><p>Columns that will only increase in value (ids or timestamps) are good candidates for BRIN indexes. Another appealing attribute is that BRIN occupies significantly less space than B-Tree indexes since it stores just the minimum and maximum values per range.</p><p>Creating BRIN indexes is quite straightforward:</p><pre>CREATE INDEX index_name ON table_name USING BRIN (column_name);</pre><h3>And that’s a wrap!</h3><p>Oof that was a fun ride, wasn’t it? Since it was also a long one, I’ll leave you with a parting gift: a small TL;DR for this article.</p><ul><li><strong>BTREE</strong> is good for <strong>comparison and sorting. </strong>It is the default access method for PostgreSQL.</li><li><strong>HASH </strong>is good for <strong>equality.</strong> Takes less space than <strong>BTREE, </strong>but should not be used prior to PostgreSQL 10.</li><li><strong>GIN </strong>is good for<strong> full-text search. </strong>The indexed columns must be of the tsvector type.</li><li><strong>GIST </strong>is good for <strong>full-text and geospatial search.</strong> The indexed column must be a tsvector or a tsquery. It takes less space than GIN, but it does additional look-ups.</li><li><strong>SPGIST </strong>is good for <strong>searching non-intersecting clusters.</strong> It is good for quadtrees, k-dimensional trees, and redix trees.</li><li><strong>BRIN </strong>is good for <strong>searching sequential data. </strong>It occupies less space than <strong>BTREE, </strong>but it’s less versatile because of it.</li></ul><p>As with any subject, there is always more to learn. This article only covers the surface of it.</p><p>So if you’d like to dig deeper, here are some valuable resources:</p><ul><li><a href="https://www.postgresql.org/docs/12/internals.html">PostgreSQL internals documentation</a></li><li><a href="https://www.postgresql.org/docs/10/textsearch.html">PostgreSQL documentation for Full Text Search</a></li><li><a href="https://habr.com/en/company/postgrespro/blog/441962/">A series of articles that take a thorough look at PostgreSQL indexes</a></li></ul><p>I hope you’ve found this article helpful. Take care!</p><p>—</p><p>Interested in joining our team? <a href="https://hire.heyjobs.co/en-us/careers">Browse our open positions</a> or check out what we do at <a href="https://www.heyjobs.co/en-de">HeyJobs</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc58a2f5ba96" width="1" height="1" alt=""><hr><p><a href="https://medium.com/heyjobs-tech/a-gentle-introduction-to-postgresql-indexes-fc58a2f5ba96">A gentle introduction to PostgreSQL indexes</a> was originally published in <a href="https://medium.com/heyjobs-tech">HeyJobs Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>