Best practice to keep track of User's last API use date-timeWhy is iterating through a large Django QuerySet consuming massive amounts of memory?Best practices for SQL varchar column lengthRDBMS - Lock Table to prevent InsertsIs there any way to know what rows are changed in statement level trigger in postgreSQL?Fire SQL Trigger only when a particular user update the rowPostgres: How to prevent read with explicit lock?how do concurrent reads affect Postgres?postgres acquire row-level lockBest way to update a HTML table in real timeatomically compare and update multiple rows using postgres transaction with maximum concurrency

Garage door sticks on a bolt

Re-entering the UK after overstaying in 2008

Can the President of the US limit First Amendment rights?

Airport Security - advanced check, 4th amendment breach

How do we know neutrons have no charge?

What does a textbook look like while you are writing it?

Lighthouse Alternatives

Are there types of animals that can't make the trip to space? (physiologically)

Could Boris Johnson face criminal charges for illegally proroguing Parliament?

What's the global, general word that stands for "center tone of a song"?

Bothered by watching coworkers slacking off

Why has Speaker Pelosi been so hesitant to impeach President Trump?

Can Familiars read and use spell scrolls?

Get the exact size of files retrieved by find output

Phonetic distortion when words are borrowed among languages

Giving a good fancy look to a simple table

GPLv3 forces us to make code available, but to who?

How important is knowledge of trig identities for use in Calculus

Can I bring this power bank on board the aircraft?

MaxCounters solution in C# from Codility

What is the difference between increasing volume and increasing gain?

Does the 'java' command compile Java programs?

What is the use of command?

How do my husband and I get over our fear of having another difficult baby?



Best practice to keep track of User's last API use date-time


Why is iterating through a large Django QuerySet consuming massive amounts of memory?Best practices for SQL varchar column lengthRDBMS - Lock Table to prevent InsertsIs there any way to know what rows are changed in statement level trigger in postgreSQL?Fire SQL Trigger only when a particular user update the rowPostgres: How to prevent read with explicit lock?how do concurrent reads affect Postgres?postgres acquire row-level lockBest way to update a HTML table in real timeatomically compare and update multiple rows using postgres transaction with maximum concurrency






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0















I have API service that users with given API-key can use with Postgres database.



Currently, I'm updating 'users' table's "last_usage_date" column on every usage of API.



But now I see the 'users' table gets pretty busy all the time because there are so many APIs fired. (the table is almost always updating)



I have three questions



  1. If a row of the table is updated, will it lock the whole table? Will it slow down(or delay) next look-ups or insert/update? Any performance concerns?


  2. If postgres supports row-level locking, will the fact that the user-row is being updated makes other APIs to wait(delay) if it's about to take a look at that row??


  3. If this is a bad design to keep track of the last_api_usage_date, what will be the best practice?


Thanks in advance!










share|improve this question





















  • 3





    This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

    – Craig Meier
    Mar 28 at 20:45






  • 1





    If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

    – danblack
    Mar 28 at 23:05






  • 1





    You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

    – deceze
    Mar 29 at 15:36











  • Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

    – Andre Song
    Mar 29 at 15:36

















0















I have API service that users with given API-key can use with Postgres database.



Currently, I'm updating 'users' table's "last_usage_date" column on every usage of API.



But now I see the 'users' table gets pretty busy all the time because there are so many APIs fired. (the table is almost always updating)



I have three questions



  1. If a row of the table is updated, will it lock the whole table? Will it slow down(or delay) next look-ups or insert/update? Any performance concerns?


  2. If postgres supports row-level locking, will the fact that the user-row is being updated makes other APIs to wait(delay) if it's about to take a look at that row??


  3. If this is a bad design to keep track of the last_api_usage_date, what will be the best practice?


Thanks in advance!










share|improve this question





















  • 3





    This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

    – Craig Meier
    Mar 28 at 20:45






  • 1





    If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

    – danblack
    Mar 28 at 23:05






  • 1





    You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

    – deceze
    Mar 29 at 15:36











  • Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

    – Andre Song
    Mar 29 at 15:36













0












0








0








I have API service that users with given API-key can use with Postgres database.



Currently, I'm updating 'users' table's "last_usage_date" column on every usage of API.



But now I see the 'users' table gets pretty busy all the time because there are so many APIs fired. (the table is almost always updating)



I have three questions



  1. If a row of the table is updated, will it lock the whole table? Will it slow down(or delay) next look-ups or insert/update? Any performance concerns?


  2. If postgres supports row-level locking, will the fact that the user-row is being updated makes other APIs to wait(delay) if it's about to take a look at that row??


  3. If this is a bad design to keep track of the last_api_usage_date, what will be the best practice?


Thanks in advance!










share|improve this question
















I have API service that users with given API-key can use with Postgres database.



Currently, I'm updating 'users' table's "last_usage_date" column on every usage of API.



But now I see the 'users' table gets pretty busy all the time because there are so many APIs fired. (the table is almost always updating)



I have three questions



  1. If a row of the table is updated, will it lock the whole table? Will it slow down(or delay) next look-ups or insert/update? Any performance concerns?


  2. If postgres supports row-level locking, will the fact that the user-row is being updated makes other APIs to wait(delay) if it's about to take a look at that row??


  3. If this is a bad design to keep track of the last_api_usage_date, what will be the best practice?


Thanks in advance!







postgresql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 29 at 15:38







Andre Song

















asked Mar 28 at 20:39









Andre SongAndre Song

5911 bronze badges




5911 bronze badges










  • 3





    This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

    – Craig Meier
    Mar 28 at 20:45






  • 1





    If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

    – danblack
    Mar 28 at 23:05






  • 1





    You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

    – deceze
    Mar 29 at 15:36











  • Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

    – Andre Song
    Mar 29 at 15:36












  • 3





    This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

    – Craig Meier
    Mar 28 at 20:45






  • 1





    If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

    – danblack
    Mar 28 at 23:05






  • 1





    You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

    – deceze
    Mar 29 at 15:36











  • Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

    – Andre Song
    Mar 29 at 15:36







3




3





This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

– Craig Meier
Mar 28 at 20:45





This question is tagged with two different database systems. Which one are you using? If mysql, which storage engine are you using? Whether row-level locking is supported will be relevant to this question.

– Craig Meier
Mar 28 at 20:45




1




1





If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

– danblack
Mar 28 at 23:05





If you want to sacrifice a bit of accuracy for less contention you could 'UPDATE users SET last_usage_date=NOW() WHERE id=X and last_usage_date > DATE_SUB(NOW(), INTERVAL 1 HOUR)'

– danblack
Mar 28 at 23:05




1




1





You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

– deceze
Mar 29 at 15:36





You'll have to store the timestamp somewhere, and a database is as good a place as any. Your question boils down to "how many writes per second can my database handle", which has no easy answer. If done properly, the answer is hopefully a lot.

– deceze
Mar 29 at 15:36













Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

– Andre Song
Mar 29 at 15:36





Thanks for the comment guys! I updated my tags. I use Postgresql at the moment. And I don't quite get what u mean by 'which storage engine I am using'. Is there multiple versions of storage engine per database language?? Also, I'm not so sure if postgres has row-level locking. How do i check that??

– Andre Song
Mar 29 at 15:36












0






active

oldest

votes













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);














draft saved

draft discarded
















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406490%2fbest-practice-to-keep-track-of-users-last-api-use-date-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406490%2fbest-practice-to-keep-track-of-users-last-api-use-date-time%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현