Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7910347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:50:12+00:00 2026-06-03T12:50:12+00:00

Well, i’m designing a small affiliate system using PHP and Neo4J in order to

  • 0

Well, i’m designing a small affiliate system using PHP and Neo4J in order to teach myself a little more about Neo4J and how graph databases work. My original affiliate system was in MySQL and the performance gain by just migrating the design and storage to Neo4J is absurd.

However, there are some features that i’m probably doing VERY wrongly and i’m willing to see how better it could be, with some help from more experienced developers. For example, each month the system has to calculate the amount of dollars to pay to each affiliate. This follows some rules that force me to search through an entire user network.

For example, in order to calculate Joe’s monthly pay, the system has to:

Find Node Joe
function Calculate:
  Calculate amount of people referred (all tiers)
  Calculate the number of referral tiers (all tiers)
  Calculate points
  Store information inside object properties
  • tiers: Joe refers Mary who in it’s turn refers Bob. Mary is Tier 1, Bob is Tier 2, under Joe.
  • all tiers: calculate number based on Joe, Mary and Bob

So, the Calculate function looks like a recursive function. Foreach user referred by Joe, i have to run the Calculate function on him, and any of his children, until i get back to Joe and get my numbers.

This is slow as hell. I thought about using RabbitMQ or ZMQ and creating a queue for each “children process” of Joe’s calculation. I also thought about using pcntl’s forking. How can i make this recursive process inside my graph network better? What’s the best way to go through the entire tree? Queuing? Process Forking?

Another example:

Calculate(Joe)
  Joe referred Mary, Bob, Peter
  Calculate(Mary)
  Mary referred Sara, Megan
    Calculate(Sara)
    Calculate(Megan)
  Calculate(Bob)
  Bob referred Billy, Michael
    Calculate(Billy)
    Calculate(Michael)
  Calculate(Peter)
  Peter referred Charles, Max
    Calculate(Charles)
    Calculate(Max)

Now, multiplicate this for someone with 500 referrals, and each of his referrals can have more 500 people. It’s slow as hell and i have to show this on Joe’s Dashboard, each month. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:50:15+00:00Added an answer on June 3, 2026 at 12:50 pm

    with Neo4j and Cypher, you could do something along the lines of this Graph Gist: http://tinyurl.com/7vryzwz

    basically, the Cypher ( http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html) query is

    START referrer=node(1)
    MATCH path=referrer-[:referred*1..]->refferee
    RETURN referrer,refferee, length(path) as generation
    ORDER BY length(path) asc
    

    Does that help?

    /peter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well I am using the following code to take any old image into a
Well, not random, because its the same every time, but #include<iostream> using namespace std;
Well, to begin with, I'm using Visual Studio 2008 on a 32-bits Windows XP
Well, I am abit confuse using these \r,\n,\t etc things. Because I read online
Well after much messing about I have finally got a query that gives sales
Well I'm making an program about payrolls and I'm stuck. In the program, after
well. For a single module in terms of regression testing In order to improve
Well, sorry for the question, is more like a general culture one (haven't found
Well, I know there is a lots of posts about it, but I have
well I'm trying to create a great playlist of music, only using a sigle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.